olp-cpp-sdk  1.22.0
AuthenticationClient.h
1 /*
2  * Copyright (C) 2019-2023 HERE Europe B.V.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * SPDX-License-Identifier: Apache-2.0
17  * License-Filename: LICENSE
18  */
19 
20 #pragma once
21 
22 #include <chrono>
23 #include <functional>
24 #include <memory>
25 #include <string>
26 
27 #include <olp/authentication/AppleSignInProperties.h>
28 #include <olp/authentication/AuthenticationApi.h>
29 #include <olp/authentication/AuthenticationCredentials.h>
30 #include <olp/authentication/AuthenticationSettings.h>
31 #include <olp/authentication/AuthorizeRequest.h>
32 #include <olp/authentication/SignInResult.h>
33 #include <olp/authentication/SignInUserResult.h>
34 #include <olp/authentication/SignOutResult.h>
35 #include <olp/authentication/SignUpResult.h>
36 #include <olp/authentication/Types.h>
37 #include <olp/core/client/ApiResponse.h>
38 #include <olp/core/client/CancellationToken.h>
39 #include <boost/optional.hpp>
40 
44 namespace olp {
45 
49 namespace authentication {
50 class AuthenticationClientImpl;
51 
59 class AUTHENTICATION_API AuthenticationClient {
60  public:
68  boost::optional<std::string> scope{boost::none};
69 
76  boost::optional<std::string> device_id{boost::none};
77 
85  std::chrono::seconds expires_in{0};
86  };
87 
91  struct UserProperties {
95  std::string email;
96 
100  std::string password;
101 
109  unsigned int expires_in{0};
110  };
111 
121  std::string access_token;
122 
130  std::string country_code;
131 
139  std::string language;
140 
147  std::string email;
148 
157  unsigned int expires_in{0};
158  };
159 
168  std::string email;
169 
173  std::string password;
174 
178  std::string date_of_birth;
179 
183  std::string first_name;
184 
188  std::string last_name;
189 
194  std::string country_code;
195 
200  std::string language;
201 
205  bool marketing_enabled{false};
206 
212  std::string phone_number;
213 
222  std::string realm;
223 
229  std::string invite_token;
230  };
231 
243  std::string access_token;
244 
251  std::string refresh_token;
252 
261  unsigned int expires_in{0};
262  };
263 
266 
269 
272 
275 
278 
281 
284 
287 
295  virtual ~AuthenticationClient();
296 
299 
302 
305 
308 
326  client::CancellationToken SignInClient(AuthenticationCredentials credentials,
327  SignInProperties properties,
328  SignInClientCallback callback);
329 
345  client::CancellationToken SignInHereUser(
346  const AuthenticationCredentials& credentials,
347  const UserProperties& properties, const SignInUserCallback& callback);
348 
370  client::CancellationToken SignInFederated(
371  AuthenticationCredentials credentials, std::string request_body,
372  SignInUserCallback callback);
373 
393  client::CancellationToken SignInFacebook(
394  const AuthenticationCredentials& credentials,
395  const FederatedProperties& properties,
396  const SignInUserCallback& callback);
397 
417  client::CancellationToken SignInArcGis(
418  const AuthenticationCredentials& credentials,
419  const FederatedProperties& properties,
420  const SignInUserCallback& callback);
421 
436  client::CancellationToken SignInApple(AppleSignInProperties properties,
437  SignInUserCallback callback);
438 
461  client::CancellationToken SignInRefresh(
462  const AuthenticationCredentials& credentials,
463  const RefreshProperties& properties, const SignInUserCallback& callback);
464 
482  client::CancellationToken SignUpHereUser(
483  const AuthenticationCredentials& credentials,
484  const SignUpProperties& properties, const SignUpCallback& callback);
485 
509  client::CancellationToken AcceptTerms(
510  const AuthenticationCredentials& credentials,
511  const std::string& reacceptance_token,
512  const SignInUserCallback& callback);
513 
533  client::CancellationToken SignOut(
534  const AuthenticationCredentials& credentials,
535  const std::string& user_access_token,
536  const SignOutUserCallback& callback);
537 
552  client::CancellationToken IntrospectApp(std::string access_token,
553  IntrospectAppCallback callback);
554 
571  client::CancellationToken Authorize(std::string access_token,
572  AuthorizeRequest request,
573  AuthorizeCallback callback);
574 
596  client::CancellationToken GetMyAccount(std::string access_token,
597  UserAccountInfoCallback callback);
598 
599  private:
600  std::shared_ptr<AuthenticationClientImpl> impl_;
601 };
602 
603 } // namespace authentication
604 } // namespace olp
The Apple sign-in properties.
Definition: AppleSignInProperties.h:30
Provides programmatic access to the HERE Account Authentication Service.
Definition: AuthenticationClient.h:59
AuthenticationClient(AuthenticationSettings settings)
Creates the AuthenticationClient instance.
Callback< SignOutResult > SignOutUserCallback
The callback type of the user sign-out response.
Definition: AuthenticationClient.h:286
Callback< SignInUserResult > SignInUserCallback
The callback type of the user sign-in response.
Definition: AuthenticationClient.h:274
AuthenticationClient & operator=(const AuthenticationClient &)=delete
A copy assignment operator.
Callback< SignInResult > SignInClientCallback
The callback type of the client sign-in response.
Definition: AuthenticationClient.h:268
AuthenticationClient(const AuthenticationClient &)=delete
A copy constructor.
AuthenticationClient(AuthenticationClient &&) noexcept
A default move constructor.
Callback< SignUpResult > SignUpCallback
The callback type of the user sign-up response.
Definition: AuthenticationClient.h:280
The access key ID and access key secret that you got from the HERE Account as a part of the onboardin...
Definition: AuthenticationCredentials.h:45
Encapsulates the fields required to make a policy decision for a given request context against the HE...
Definition: AuthorizeRequest.h:47
Represents a request outcome.
Definition: ApiResponse.h:65
Callback< AuthorizeResult > AuthorizeCallback
Called when the user decision request is completed.
Definition: Types.h:52
Callback< model::UserAccountInfoResponse > UserAccountInfoCallback
Called when the get user account request is completed.
Definition: Types.h:58
Callback< IntrospectAppResult > IntrospectAppCallback
Called when the user introspect app request is completed.
Definition: Types.h:46
std::function< void(Response< ResultType >)> Callback
The callback template type.
Definition: Types.h:40
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24
The federated (Facebook, Google, ArcGIS) sign-in properties structure.
Definition: AuthenticationClient.h:116
std::string access_token
(Required) A valid Facebook, Google, or ArcGIS access token obtained from the Facebook,...
Definition: AuthenticationClient.h:121
std::string language
The code of the language that you speak in the ISO 639-1 alpha-2 format.
Definition: AuthenticationClient.h:139
std::string email
Your valid email address.
Definition: AuthenticationClient.h:147
std::string country_code
The code of the country in which you live in the ISO 3166-1 alpha-3 format.
Definition: AuthenticationClient.h:130
Used to generate a new access token and contains token values returned as a response to the user sign...
Definition: AuthenticationClient.h:236
std::string refresh_token
(Required) The refresh token value returned in the response of the user sign-in operation.
Definition: AuthenticationClient.h:251
std::string access_token
(Required) The access token value returned as a response to the user sign-in operation.
Definition: AuthenticationClient.h:243
General properties used to sign in with client credentials.
Definition: AuthenticationClient.h:64
Used to create a new HERE account for the specified user with the email and password that are your lo...
Definition: AuthenticationClient.h:164
std::string email
(Required) Your valid email address.
Definition: AuthenticationClient.h:168
std::string language
(Required) The code of the language that you speak in the ISO 639-1 alpha-2 format.
Definition: AuthenticationClient.h:200
std::string password
(Required) Your plain-text password.
Definition: AuthenticationClient.h:173
std::string date_of_birth
(Required) Your date of birth in the following format: dd/mm/yyyy.
Definition: AuthenticationClient.h:178
std::string phone_number
(Optional) Your valid phone number.
Definition: AuthenticationClient.h:212
std::string last_name
(Required) Your last name.
Definition: AuthenticationClient.h:188
std::string first_name
(Required) Your first name.
Definition: AuthenticationClient.h:183
std::string realm
(Optional) The realm in which you want to create the user.
Definition: AuthenticationClient.h:222
std::string country_code
(Required) The code of the country in which you live in the ISO 3166-1 alpha-3 format.
Definition: AuthenticationClient.h:194
std::string invite_token
(Optional) The valid Authorization Invite Token with a payload that matches the user email and reques...
Definition: AuthenticationClient.h:229
The user sign-in properties struct.
Definition: AuthenticationClient.h:91
std::string password
(Required) Your plain-text password.
Definition: AuthenticationClient.h:100
std::string email
(Required) Your valid email address.
Definition: AuthenticationClient.h:95
Configures the TokenEndpoint instance.
Definition: AuthenticationSettings.h:49