SmartSwitchAuthenticateFacebook
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. Use this function to keep a clean designflow from anonymous to signed profiles
Authenticate the user with brainCloud using their Facebook Credentials
Method Parameters
Parameter | Description |
---|---|
userId | The userId |
facebookId | The Facebook ID of the user |
facebookToken | The validated token from the Facebook SDK |
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 facebookId = "userFacebookId";
string token = "tokenFromFacebook";
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.SmartSwitchAuthenticateFacebook(
facebookId, token, forceCreate,
successCallback, failureCallback);
const char* facebookId = "userFacebookId";
const char* token = "tokenFromFacebook";
_bc->smartSwitchAuthenticateFacebook(
userId,
token,
true,
this);
NSString* externalID = @"userFacebookId";
NSString* authToken = @"tokenFromFacebook";
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[_bc smartSwitchAuthenticateExternal:externalID
authenticationToken:authToken
forceCreate:true
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
public void smartSwitchAuthenticateFacebook(String fbUserId, String fbAuthToken, boolean forceCreate, IAuthenticationServiceCallback callback)
var facebookId = "userFacebookId";
var token = "tokenFromFacebook";
var forceCreate = true;
_bc.smartSwitchAuthenticateFacebook(facebookId, token, forceCreate, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var facebookId = "userFacebookId";
var token = "tokenFromFacebook";
var forceCreate = true;
ServerResponse result = await _bc.smartSwitchAuthenticateFacebook(
fbUserId:facebookId,
fbAuthToken:token,
forceCreate:forceCreate);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
// N/A
// N/A
JSON Response
var facebookId = "userFacebookId";
var token = "tokenFromFacebook";
var forceCreate = true;
_bc.smartSwitchAuthenticateFacebook(facebookId, token, forceCreate, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});