API Reference of GS2-Auth SDK for Game Engine

Model

EzAccessToken

TypeRequireDefaultLimitationDescription
tokenstring~ 1024 charsAccess token
userIdstring~ 128 charsUser Id
expirelongDifference from current time(1 hours)Effective date

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~ 1024 charsencryption key GRN
bodystring~ 1048576 charsAccount credentials to be signed
signaturestring~ 1024 charssignature

Result

TypeDescription
tokenstringaccess token
userIdstringUser Id
expirelongeffective date

Implementation Example

    var domain = gs2.Auth.AccessToken(
    );
    var result = await domain.LoginAsync(
        keyId: "key-0001",
        body: "body",
        signature: "signature"
    );
    var token = result.Token;
    var userId = result.UserId;
    var expire = result.Expire;
    var domain = gs2.Auth.AccessToken(
    );
    var future = domain.LoginFuture(
        keyId: "key-0001",
        body: "body",
        signature: "signature"
    );
    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(
        "key-0001",
        "body",
        "signature"
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }
    const auto Token = Result->Token;
    const auto UserId = Result->UserId;
    const auto Expire = Result->Expire;