Gamebase SDK for Unity 2.74.0 Toast Gamebase Platform

Loading...
Searching...
No Matches

## ◆ AddMappingForcibly() [1/4]

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

Forcibly trying to map the currently authenticated user identifier of Gamebase with the credential of external authentication provider.

Since
  Added 2.2.0.

Parameters

  credentialInfo | The credentialInfo which is credential of authentication provider.
  forcingMappingKey | The key string which is necessary to map forcibly with the provider that is already mappped with another account.
  callback | Mapping result callback, returns the authentication token as a result of mapping.

Example Usage :

public void AddMappingForciblyWithCredentialInfoSample(Dictionary<string, object> credential)
{
Gamebase.AddMapping(credential, (authToken, error) =>
{
if (Gamebase.IsSuccess(error) == true)
{
// AddMapping succeeded.
}
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)
{
// Before calling the mapping forcibly api, You should get this ForcingMappingTicket and ForcingMappingKey string for this method parameter.
GamebaseResponse.Auth.ForcingMappingTicket forcingMappingTicket = GamebaseResponse.Auth.ForcingMappingTicket.From(error);
if (forcingMappingTicket == null)
{
// Unexpected error occurred. Contact Administrator.
}
// Try to add mapping forcibly with the ForcingMappingKey.
Gamebase.AddMappingForcibly(credential, forcingMappingTicket.forcingMappingKey, (innerAuthToken, innerError) =>
{
if (Gamebase.IsSuccess(innerError) == true)
{
string userId = innerAuthToken.member.userId;
Debug.Log(string.Format("AddMappingForcibly succeeded. Gamebase userId is {0}", userId));
}
else
{
// Check the error code and handle the error appropriately.
Debug.Log(string.Format("AddMappingForcibly failed. error is {0}", innerError));
}
});
}
else
{
// Check the error code and handle the error appropriately.
Debug.Log(string.Format("AddMapping failed. error is {0}", error));
}
}
});
}
Toast.Gamebase.Gamebase.AddMapping
static void AddMapping(string providerName, GamebaseCallback.GamebaseDelegate< GamebaseResponse.Auth.AuthToken > callback)
Try mapping to another IdP while logged-in to a specific IdP.
Definition: Gamebase.cs:1068
Toast.Gamebase.Gamebase.IsSuccess
static bool IsSuccess(GamebaseError error)
Return true if the GamebaseException object is null or the error code is zero.
Definition: Gamebase.cs:57
Toast.Gamebase.Gamebase
The Gamebase class is core of Gamebase service.
Definition: Gamebase.cs:11