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

◆ AddMappingForcibly() [4/4]

static void AddMappingForcibly ( string providerName,
string forcingMappingKey,
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 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.
callbackMapping result callback, returns the authentication token as a result of mapping.

Example Usage :

public void AddMappingForciblySample(string idPName)
{
Gamebase.AddMapping(idPName, (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)
{
// 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, (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