GS2-Auth SDK for Game Engine API Reference

Specifications of models and API references for GS2-Auth SDK for Game Engine

Model

EzAccessToken

Access token

A model that manages access tokens issued after user authentication. Access tokens are used to identify a session while a user is logged in to the service. Tokens have an expiration time, and when they expire, re-authentication is required.

TypeConditionRequiredDefaultValue LimitsDescription
tokenstring
~ 1024 charsAccess token
A token used to authenticate access.
This token is automatically generated by the system and identifies the user’s session.
userIdstring
~ 128 charsUser ID
expirelongThe absolute time 1 hour after the current timeExpiration time
A timestamp indicating the expiration time of the token. When this date is reached, the token becomes invalid.
Unix time, milliseconds

Methods

login

Log in to GS2 using account credentials

Pass the body and signature obtained from GS2-Account::Authentication to log in and receive an access token. The access token is a temporary login credential valid for 1 hour, and is required to use GS2 services as a specific player.

In most cases, you do not need to call this API directly. The Unity and Unreal Engine 5 SDKs provide Profile::Login, which combines GS2-Account::Authentication and this API into a single call. See Initialization / Game Engine for details.

Request

TypeConditionRequiredDefaultValue LimitsDescription
keyIdstring“grn:gs2:{region}:{ownerId}:key:default:key:default”~ 1024 charsEncryption Key GRN
bodystring
~ 524288 charsSigned authentication payload
signaturestring
~ 1024 charsSignature

Result

TypeDescription
tokenstringAccess token
A token used to authenticate access.
This token is automatically generated by the system and identifies the user’s session.
userIdstringUser ID
expirelongExpiration time
A timestamp indicating the expiration time of the token. When this date is reached, the token becomes invalid.
Unix time, milliseconds

Implementation Example

    var domain = gs2.Auth.AccessToken(
    );
    var result = await domain.LoginAsync(
        body: "body",
        signature: "signature",
        keyId: "key-0001"
    );
    var token = result.Token;
    var userId = result.UserId;
    var expire = result.Expire;
    var domain = gs2.Auth.AccessToken(
    );
    var future = domain.LoginFuture(
        body: "body",
        signature: "signature",
        keyId: "key-0001"
    );
    yield return future;
    if (future.Error != null)
    {
        onError.Invoke(future.Error, null);
        yield break;
    }
    var token = future.Result.Token;
    var userId = future.Result.UserId;
    var expire = future.Result.Expire;
    const auto Domain = Gs2->Auth->AccessToken(
    );
    const auto Future = Domain->Login(
        "body", // body
        "signature", // signature
        "key-0001" // keyId
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }
    const auto Result = Future->GetTask().Result();
    const auto Token = Result->Token;
    const auto UserId = Result->UserId;
    const auto Expire = Result->Expire;