Skip to content

Commit 346f667

Browse files
Remove deprecated code from Authentication (#1401)
Removed outdated code and adapted to the recommended alternatives Relates-To: OAM-2009 Signed-off-by: Andrey Kashcheev <ext-andrey.kashcheev@here.com>
1 parent 3c5794f commit 346f667

File tree

16 files changed

+47
-331
lines changed

16 files changed

+47
-331
lines changed

olp-cpp-sdk-authentication/include/olp/authentication/AuthenticationClient.h

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2022 HERE Europe B.V.
2+
* Copyright (C) 2019-2023 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@
2727
#include <olp/authentication/AppleSignInProperties.h>
2828
#include <olp/authentication/AuthenticationApi.h>
2929
#include <olp/authentication/AuthenticationCredentials.h>
30-
#include <olp/authentication/AuthenticationError.h>
3130
#include <olp/authentication/AuthenticationSettings.h>
3231
#include <olp/authentication/AuthorizeRequest.h>
3332
#include <olp/authentication/SignInResult.h>
@@ -396,34 +395,6 @@ class AUTHENTICATION_API AuthenticationClient {
396395
const FederatedProperties& properties,
397396
const SignInUserCallback& callback);
398397

399-
/**
400-
* @brief Signs in with your valid Google token and requests your user access
401-
* token.
402-
*
403-
* If this is the first time that you use Google to sign in,
404-
* a new HERE Account is automatically created and filled in with the data
405-
* from your Google account, including your name and email.
406-
*
407-
* @param credentials The `AuthenticationCredentials` instance.
408-
* @param properties The `FederatedProperties` structure.
409-
* @param callback The `SignInUserCallback` method that is called when
410-
* the user sign-in request is completed. If successful, the returned HTTP
411-
* status is 200. If a new account is created as a part of the sign-in request
412-
* and terms must be accepted, the returned HTTP status is 201. Otherwise,
413-
* check the response error.
414-
*
415-
* @return The `CancellationToken` instance that can be used to cancel
416-
* the request.
417-
*
418-
* @deprecated Will be removed by 12.2020.
419-
*/
420-
OLP_SDK_DEPRECATED(
421-
"Sign in with Google token is deprecated and will be removed by 12.2020")
422-
client::CancellationToken SignInGoogle(
423-
const AuthenticationCredentials& credentials,
424-
const FederatedProperties& properties,
425-
const SignInUserCallback& callback);
426-
427398
/**
428399
* @brief Signs in with your valid ArcGIS token and requests your user access
429400
* token.

olp-cpp-sdk-authentication/include/olp/authentication/AuthenticationError.h

Lines changed: 0 additions & 41 deletions
This file was deleted.

olp-cpp-sdk-authentication/include/olp/authentication/TokenProvider.h

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2021 HERE Europe B.V.
2+
* Copyright (C) 2019-2023 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -59,9 +59,6 @@ class AUTHENTICATION_API TokenProviderImpl {
5959
*/
6060
TokenProviderImpl(Settings settings, std::chrono::seconds minimum_validity);
6161

62-
/// @copydoc TokenProvider::operator()()
63-
std::string operator()() const;
64-
6562
/// @copydoc TokenProvider::operator()(client::CancellationContext&)
6663
client::OauthTokenResponse operator()(
6764
client::CancellationContext& context) const;
@@ -128,23 +125,6 @@ class TokenProvider {
128125
*/
129126
operator bool() const { return impl_->IsTokenResponseOK(); }
130127

131-
/**
132-
* @brief Casts the `TokenProvider` instance to the `std::string` type.
133-
*
134-
* Returns the access token string if the response is successful. Otherwise,
135-
* returns an empty string.
136-
*
137-
* @returns The access token string if the response is successful; an empty
138-
* string otherwise.
139-
*
140-
* @deprecated Will be removed by 10.2022. Use the operator with
141-
* `CancellationContext` instead.
142-
*/
143-
OLP_SDK_DEPRECATED(
144-
"Will be removed by 10.2022. Use the operator with `CancellationContext` "
145-
"instead.")
146-
std::string operator()() const { return impl_->operator()(); }
147-
148128
/**
149129
* @brief Returns the access token or an error.
150130
*

olp-cpp-sdk-authentication/include/olp/authentication/TokenResult.h

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2021 HERE Europe B.V.
2+
* Copyright (C) 2019-2023 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,8 +19,6 @@
1919

2020
#pragma once
2121

22-
#include <olp/core/porting/deprecated.h>
23-
2422
#include <chrono>
2523
#include <ctime>
2624
#include <string>
@@ -34,9 +32,8 @@ namespace authentication {
3432
* @brief A parsed response received from the OAuth2.0 token endpoint.
3533
*
3634
* You can get the following information: the access token issued by
37-
* the authorization server (`GetAccessToken`), its expiry time
38-
* (`GetExpiryTime`), HTTP status code (`GetHttpStatus`),
39-
* and error description (`GetErrorResponse`) in case of a failure.
35+
* the authorization server (`GetAccessToken`), and its expiry time
36+
* (`GetExpiryTime`).
4037
*/
4138
class AUTHENTICATION_API TokenResult {
4239
public:
@@ -46,22 +43,16 @@ class AUTHENTICATION_API TokenResult {
4643
* @param access_token The access token issued by the authorization server.
4744
* @param expiry_time The Epoch time when the token expires, or -1 if
4845
* the token is invalid.
49-
* @param http_status The status code of the HTTP response.
50-
* @param error The error description of the request.
5146
*/
52-
TokenResult(std::string access_token, time_t expiry_time, int http_status,
53-
ErrorResponse error);
47+
TokenResult(std::string access_token, time_t expiry_time);
5448

5549
/**
5650
* @brief Creates the `TokenResult` instance.
5751
*
5852
* @param access_token The access token issued by the authorization server.
5953
* @param expires_in The expiry time of the access token.
60-
* @param http_status The status code of the HTTP response.
61-
* @param error The error description of the request.
6254
*/
63-
TokenResult(std::string access_token, std::chrono::seconds expires_in,
64-
int http_status, ErrorResponse error);
55+
TokenResult(std::string access_token, std::chrono::seconds expires_in);
6556
/**
6657
* @brief Creates the default `TokenResult` instance.
6758
*/
@@ -90,40 +81,10 @@ class AUTHENTICATION_API TokenResult {
9081
*/
9182
std::chrono::seconds GetExpiresIn() const;
9283

93-
/**
94-
* @brief Gets the HTTP status code.
95-
*
96-
* @return The status code of the HTTP response if a positive value is
97-
* returned. A negative value indicates a possible networking error. If you
98-
* get the negative value, retry the request.
99-
*
100-
* @deprecated Will be removed by 10.2022. Use
101-
* `TokenResponse::GetError().GetHttpStatusCode()` instead.
102-
*/
103-
OLP_SDK_DEPRECATED(
104-
"Will be removed by 10.2022. Use "
105-
"`TokenResponse::GetError().GetHttpStatusCode()` instead.")
106-
int GetHttpStatus() const;
107-
108-
/**
109-
* @brief Gets an error description.
110-
*
111-
* @return The error description of the failed request.
112-
*
113-
* @deprecated Will be removed by 10.2022. Use
114-
* `TokenResponse::GetError().GetMessagee()` instead.
115-
*/
116-
OLP_SDK_DEPRECATED(
117-
"Will be removed by 10.2022. Use "
118-
"`TokenResponse::GetError().GetMessagee()` instead.")
119-
ErrorResponse GetErrorResponse() const;
120-
12184
private:
12285
std::string access_token_;
123-
time_t expiry_time_;
124-
std::chrono::seconds expires_in_;
125-
int http_status_;
126-
ErrorResponse error_;
86+
time_t expiry_time_{};
87+
std::chrono::seconds expires_in_{};
12788
};
12889

12990
} // namespace authentication

olp-cpp-sdk-authentication/include/olp/authentication/Types.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 HERE Europe B.V.
2+
* Copyright (C) 2020-2023 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@
2121

2222
#include <memory>
2323

24-
#include <olp/authentication/AuthenticationError.h>
2524
#include <olp/authentication/AuthorizeResult.h>
2625
#include <olp/authentication/IntrospectAppResult.h>
2726
#include <olp/authentication/TokenResult.h>
@@ -34,7 +33,7 @@ namespace authentication {
3433

3534
/// The response template type.
3635
template <typename ResultType>
37-
using Response = client::ApiResponse<ResultType, AuthenticationError>;
36+
using Response = client::ApiResponse<ResultType, client::ApiError>;
3837

3938
/// The callback template type.
4039
template <typename ResultType>

olp-cpp-sdk-authentication/src/AuthenticationClient.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 HERE Europe B.V.
2+
* Copyright (C) 2019-2023 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
2222
#include <utility>
2323

2424
#include "AuthenticationClientImpl.h"
25-
#include "olp/authentication/AuthenticationError.h"
2625
#include "olp/authentication/AuthorizeRequest.h"
2726
#include "olp/core/client/ApiError.h"
2827
#include "olp/core/client/CancellationToken.h"
@@ -68,13 +67,6 @@ client::CancellationToken AuthenticationClient::SignInFacebook(
6867
credentials, FederatedSignInType::FacebookSignIn, properties, callback);
6968
}
7069

71-
client::CancellationToken AuthenticationClient::SignInGoogle(
72-
const AuthenticationCredentials& credentials,
73-
const FederatedProperties& properties, const SignInUserCallback& callback) {
74-
return impl_->SignInFederated(credentials, FederatedSignInType::GoogleSignIn,
75-
properties, callback);
76-
}
77-
7870
client::CancellationToken AuthenticationClient::SignInArcGis(
7971
const AuthenticationCredentials& credentials,
8072
const FederatedProperties& properties, const SignInUserCallback& callback) {

olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2022 HERE Europe B.V.
2+
* Copyright (C) 2020-2023 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -84,7 +84,6 @@ constexpr auto kFamilyName = "familyName";
8484
constexpr auto kClientGrantType = "client_credentials";
8585
constexpr auto kUserGrantType = "password";
8686
constexpr auto kFacebookGrantType = "facebook";
87-
constexpr auto kGoogleGrantType = "google";
8887
constexpr auto kArcgisGrantType = "arcgis";
8988
constexpr auto kAppleGrantType = "jwtIssNotHERE";
9089
constexpr auto kRefreshGrantType = "refresh_token";
@@ -365,13 +364,13 @@ TimeResponse AuthenticationClientImpl::ParseTimeResponse(
365364
document.ParseStream(stream);
366365

367366
if (!document.IsObject()) {
368-
return AuthenticationError(client::ErrorCode::InternalFailure,
369-
"JSON document root is not an Object type");
367+
return client::ApiError(client::ErrorCode::InternalFailure,
368+
"JSON document root is not an Object type");
370369
}
371370

372371
const auto timestamp_it = document.FindMember("timestamp");
373372
if (timestamp_it == document.MemberEnd() || !timestamp_it->value.IsUint()) {
374-
return AuthenticationError(
373+
return client::ApiError(
375374
client::ErrorCode::InternalFailure,
376375
"JSON document must contain timestamp integer field");
377376
}
@@ -390,7 +389,7 @@ TimeResponse AuthenticationClientImpl::GetTimeFromServer(
390389
OLP_SDK_LOG_WARNING_F(
391390
kLogTag, "Failed to get time from server, status=%d, response='%s'",
392391
http_result.status, response.c_str());
393-
return AuthenticationError(http_result.status, http_result.response.str());
392+
return client::ApiError(http_result.status, http_result.response.str());
394393
}
395394

396395
auto server_time = ParseTimeResponse(http_result.response);
@@ -842,9 +841,6 @@ AuthenticationClientImpl::GenerateFederatedBody(
842841
case FederatedSignInType::FacebookSignIn:
843842
writer.String(kFacebookGrantType);
844843
break;
845-
case FederatedSignInType::GoogleSignIn:
846-
writer.String(kGoogleGrantType);
847-
break;
848844
case FederatedSignInType::ArcgisSignIn:
849845
writer.String(kArcgisGrantType);
850846
break;

olp-cpp-sdk-authentication/src/AuthenticationClientImpl.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 HERE Europe B.V.
2+
* Copyright (C) 2020-2023 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
2323
#include <string>
2424

2525
#include "olp/authentication/AuthenticationClient.h"
26-
#include "olp/authentication/AuthenticationError.h"
2726
#include "olp/authentication/AuthenticationSettings.h"
2827
#include "olp/authentication/AuthorizeRequest.h"
2928
#include "olp/authentication/Types.h"
@@ -57,7 +56,7 @@ using SignOutUserCallback = AuthenticationClient::SignOutUserCallback;
5756
using TimeResponse = Response<time_t>;
5857
using TimeCallback = Callback<time_t>;
5958

60-
enum class FederatedSignInType { FacebookSignIn, GoogleSignIn, ArcgisSignIn };
59+
enum class FederatedSignInType { FacebookSignIn, ArcgisSignIn };
6160

6261
class AuthenticationClientImpl {
6362
public:

olp-cpp-sdk-authentication/src/TokenEndpoint.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2021 HERE Europe B.V.
2+
* Copyright (C) 2019-2023 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,7 +24,6 @@
2424

2525
#include <olp/authentication/AuthenticationApi.h>
2626
#include <olp/authentication/AuthenticationCredentials.h>
27-
#include <olp/authentication/AuthenticationError.h>
2827
#include <olp/authentication/Settings.h>
2928
#include <olp/authentication/Types.h>
3029
#include <olp/core/client/ApiResponse.h>

0 commit comments

Comments
 (0)