API Reference of 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 the identity of a session while a user is logged in to the service. Tokens have an expiration date, and when they expire, re-authentication is required.

TypeRequireDefaultLimitationDescription
tokenstring~ 1024 charsAccess token
userIdstring~ 128 charsUser Id
expirelongDifference from current time(1 hours)Expiration date (Unix time unit:milliseconds)

Methods

login

Log in to GS2 with the specified user ID

Specify the result of GS2-Account::Authentication for body and signature.
If body and signature are successfully verified, an access token is responded.
The access token is temporary authentication information with an expiration time of one hour, and is used to identify the game player for each service in GS2.
The Game Engine SDK for Unity and Unreal Engine 5 provides GS2-Account::Authentication and Profile::Login, which combines this API.
Profile::Login is explained in API Reference / Initialization Process / Game Engine.

Request

TypeRequireDefaultLimitationDescription
keyIdstring“grn:gs2:{region}:{ownerId}:key:default:key:default”~ 1024 charsencryption key GRN
bodystring~ 1048576 charsAccount credentials to be signed
signaturestring~ 1024 charssignature

Result

TypeDescription
tokenstringaccess token
userIdstringUser Id
expirelongeffective date (Unix time unit: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;