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

◆ AddMappingForcibly() [3/4]

static void AddMappingForcibly ( string providerName,
string forcingMappingKey,
Dictionary< string, object > additionalInfo,
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
providerNameThe providerName which is authentication provider.
forcingMappingKeyThe key string which is necessary to map forcibly with the provider that is already mappped with another account.
additionalInfoThe additionalInfo which is additional information using for mapping.
callbackCallbacks the results of mappings, returns the authentication token as a result of mappings.

Example Usage :

public void AddMappingForciblyWithAdditionalInfoSample(string idPName, Dictionary<string, object> additional)
{
Gamebase.AddMapping(idPName, additional, (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(idPName, forcingMappingTicket.forcingMappingKey, additional, (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));
}
}
});
}
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:1039
static bool IsSuccess(GamebaseError error)
Return true if the GamebaseException object is null or the error code is zero.
Definition Gamebase.cs:57
The Gamebase class is core of Gamebase service.
Definition Gamebase.cs:11