SmartSwitchAuthenticateGoogleOpenId
Smart Switch Authenticate will logout of the current profile, and switch to the new authentication type.
In event the current session was previously an anonymous account, the smart switch will delete that profile (since completely anonymous accounts are irretrievable once you switch away from them).
Use this function to keep a clean designflow from anonymous to signed profiles
Authenticate the user using a google user id (gXXX) and google authentication token.
Method Parameters
Parameter | Description |
---|---|
userid | String representation of google userid (gXXX) |
token | The authentication token derived via the google apis. |
forceCreate | Should a new profile be created for this user if the account does not exist? |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string googleId = "g123456789";
string token = "authTokenFromGoogle";
bool forceCreate = true;
SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("[Authenticate Success] {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("[Authenticate Failed] {0} {1} {2}", status, code, error));
};
_bc.SmartSwitchAuthenticateGoogleOpenId(
googleId, token, forceCreate,
successCallback, failureCallback);
const char* googleId = "g123456789";
const char* token = "authTokenFromGoogle";
_bc->smartSwitchAuthenticateGoogleOpenId(
googleId, token, true, this);
NSString* userID = @"g123456789";
NSString* token = @"authTokenFromGoogle";
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[_bc smartSwitchAuthenticateGoogleOpenId:userID
token:token
forceCreate:true
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String googleId = "g123456789";
String token = "authTokenFromGoogle";
_bc.smartSwitchAuthenticateGoogleOpenId(
googleId, token, true, this);
var googleId = "g123456789";
var token = "authTokenFromGoogle";
var forceCreate = true;
_bc.smartSwitchAuthenticateGoogleOpenId(googleId, token, forceCreate, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var googleUserAccountEmail = "example@gmail.com";
var idToken = "authTokenFromGoogle";
var forceCreate = true;
ServerResponse result = await _bc.smartSwitchAuthenticateGoogleOpenId(
googleUserAccountEmail:googleUserAccountEmail,
idToken:idToken,
forceCreate:forceCreate);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
// N/A
// N/A
JSON Response
var googleId = "g123456789";
var token = "authTokenFromGoogle";
var forceCreate = true;
_bc.smartSwitchAuthenticateGoogleOpenId(googleId, token, forceCreate, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});