Gamebase SDK for Unity 2.69.0
Toast Gamebase Platform
Loading...
Searching...
No Matches

◆ AddMapping() [1/3]

static void AddMapping ( Dictionary< string, object > credentialInfo,
GamebaseCallback::GamebaseDelegate< GamebaseResponse::Auth::AuthToken > callback )
static

This game interface allows authentication to be made with SDK provided by IdP, before applying Gamebase AddMapping with provided access token.

Since
Added 1.4.0.
Parameters
credentialInfoThe credentialInfo which is credential of authentication provider.


Parameters
callbackMapping result callback, returns the authentication token as a result of mapping.

Example Usage :

public void AddMappingWithCredentialInfoSample()
{
var credentialInfo = new Dictionary<string, object>
{
{ GamebaseAuthProviderCredential.PROVIDER_NAME, GamebaseAuthProvider.XXX },
{ GamebaseAuthProviderCredential.ACCESS_TOKEN, "${AccessToken}" }
};
Gamebase.AddMapping(credentialInfo, (authToken, error) =>
{
if (Gamebase.IsSuccess(error) == true)
{
string userId = authToken.member.userId;
Debug.Log(string.Format("AddMapping succeeded. Gamebase userId is {0}", userId));
}
else
{
// If you got this error code(AUTH_ADD_MAPPING_ALREADY_MAPPED_TO_OTHER_MEMBER) that means this user already has another account of the AuthProvider.XXX),
// You can call this method, Gamebase.addMappingForcibly() which can try to map forcibly with the AuthProvider.XXX.
if (error.code.Equals(GamebaseErrorCode.AUTH_ADD_MAPPING_ALREADY_MAPPED_TO_OTHER_MEMBER) == true)
{
// See AddMappingForcibly with credentialInfo API.
}
else
{
// Check the error code and handle the error appropriately.
Debug.Log(string.Format("AddMapping failed. error is {0}", error));
}
}
});
}