Login Service

Note

This document covers documentation for Anthill Runtime’s implementation for the Login Service. If you need the documentation for the actual service, please see Login Service instead.

How To Get Instance

Warning

To use this, you must mention this service during Library Instantiation.

LoginServicePtr service =
    online::AnthillRuntime::Instance().get<online::LoginService>();
LoginService service =
    AnthillRuntime.Get(LoginService.ID, LoginService.class);

Authenticate

Authenticates the user in the Anthill Platform

void authenticate(
    const std::string& credentialType,
    const std::string& gamespace,
    const Scopes& scopes,
    const Request::Fields& other,
    AuthenticationCallback callback,
    MergeRequiredCallback mergeRequiredCallback,
    const Scopes& shouldHaveScopes = {"*"});
// the last argument is optional

public void authenticate(
    String credentialType,
    String gamespace,
    Scopes scopes,
    Request.Fields other,
    final AuthenticationCallback callback,
    MergeRequiredCallback mergeRequiredCallback,
    Scopes shouldHaveScopes)
credentialType
A Credential Type for the authentication
gamespace
A Gamespace (alias) this authentication goes into
scopes
See Scopes of Access
other
Other possible arguments that Credential Type might additionally require.
callback
The callback that would be called once the authentication completed.
mergeRequiredCallback
The callback that would be called in rare event of Account Conflict
shouldHaveScopes
List of scopes the user should definitely acquire, or Forbidden error will be occur. Useful in cases when player is OK with not having some of scopes. A special case of single * (default) means ALL scopes being asked should be satisfied.

Please see Authenticate REST API call for more information.

Attach Credential

Attaches some credential to existing account. Technically, this call is 90% equal to Authenticate, because, by design, attach means “authenticate, but in someone’s else account”. The account in question is determined by accessToken.

void LoginService::attach(
    const std::string& accessToken,
    const std::string& credentialType,
    const std::string& gamespace,
    const Scopes& scopes,
    const Request::Fields& other,
    LoginService::AuthenticationCallback callback,
    MergeRequiredCallback mergeRequiredCallback,
    const Scopes& shouldHaveScopes)
// the last argument is optional

public void attach(
    AccessToken accessToken,
    String gamespace,
    String credentialType,
    Scopes scopes,
    Request.Fields other,
    final AuthenticationCallback callback,
    MergeRequiredCallback mergeRequiredCallback,
    Scopes shouldHaveScopes)
accessToken
An existing Access token the authentication attaches to.
credentialType
A Credential Type for the authentication.
scopes
See Scopes of Access.
other
Other possible arguments that Credential Type might additionally require.
callback
The callback that would be called once the authentication completed.
mergeRequiredCallback
The callback that would be called in rare event of Account Conflict
shouldHaveScopes
List of scopes the user should definitely acquire, or Forbidden error will be occur. Useful in cases when player is OK with not having some of scopes. A special case of single * (default) means ALL scopes being asked should be satisfied.

Please see Attach Credential REST API call for more information.

Resolve a Conflict

Resolves the occurred Account Conflict event that may happen during Attach Credential or Authenticate.

void resolve(
    const std::string& resolveToken,
    const std::string& methodToResolve,
    const std::string& resolveWith,
    const Scopes& scopes,
    const Request::Fields& other,
    AuthenticationCallback callback,
    const Scopes& shouldHaveScopes = {"*"},
    const std::string& attachTo = "");
// the last two arguments are optional

public void resolve(
    AccessToken resolveToken,
    String methodToResolve,
    String resolveWith,
    String scopes,
    Request.Fields other,
    final AuthenticationCallback callback,
    Scopes shouldHaveScopes,
    AccessToken attachTo)
resolveToken
A Resolve Token, retrieved when the conflict occurred.
methodToResolve
A way how to resolve this conflict. Should be exactly the Conflict Reason server gave in MergeRequiredCallback. For example, merge_required or multiple_accounts_attached.
resolveWith
A way to resolve this conflict. Varies for different Conflict Reasons.
other
Other possible arguments that Credential Type might additionally require.
callback
The callback that would be called once the authentication completed.
shouldHaveScopes
(Optional) List of scopes the user should definitely acquire, or Forbidden error will be occur. Useful in cases when player is OK with not having some of scopes. A special case of single * (default) means ALL scopes being asked should be satisfied.
attachTo
An existing Access token the account player originally was going to attach to. Only applicable if conflict happened during Attach Credential procedure.

Please see Resolve Conflict REST API call for more information.

Extend An Access Token

Allows to to give additional Scopes of Access to the existing Access token (account of which did not have such scopes originally), using other, more powerful account.

void extend(
    const std::string& accessToken,
    const std::string& extendWith,
    const Scopes& scopes,
    AuthenticationCallback callback);
public void extend(
    AccessToken accessToken,
    AccessToken extendWith,
    LoginService.Scopes scopes,
    final AuthenticationCallback callback)
accessToken
Access token to extend (the one to be improved)
extendWith
Access token to extend with (the one that have required scopes)
scopes
A list of scopes to improve access_token with. A single * element can be used to have all scopes the scope extend have.
callback
the callback that would be called once the token has been extended.

Please see Extend Access Token REST API call for more information.

Validate An Access Token

Checks if the given access token is valid.

void validateAccessToken(
    const std::string& accessToken,
    ValidationCallback callback);
public void validateAccessToken(
    final AccessToken token,
    final ValidationCallback callback)
accessToken
Access token to validate
callback
The callback that would be called once the token has been validated (or not).

Please see Validate Access Token REST API call for more information.