SmartSwitchAuthenticateFacebookLimited
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 |
---|---|
facebookId | The Facebook ID of the user |
facebookToken | The authentication 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;
_bc.SmartSwitchAuthenticateFacebookLimited(
facebookId, token, forceCreate, SuccessCallback, FailureCallback);
const char* facebookId = "userFacebookId";
const char* token = "tokenFromFacebook";
bool forceCreate = true;
_bc->smartSwitchAuthenticateFacebookLimited(
facebookId,
token,
forceCreate,
this);
NSString * facebookId = @"userFacebookId";
NSString * token = @"tokenFromFacebook";
BOOL forceCreate = true;
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc]
smartSwitchAuthenticateFacebookLimited:facebookId
authenticationToken:token
forceCreate:forceCreate
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String facebookId = "userFacebookId";
String token = "tokenFromFacebook";
boolean forceCreate = true;
this; // implements IServerCallback
_bc.smartSwitchAuthenticateFacebookLimited(facebookId, token, forceCreate, this);
public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
System.out.print(String.format("Failed | %d %d %s", statusCode, reasonCode, jsonError.toString()));
}
var facebookId = "userFacebookId";
var token = "tokenFromFacebook";
var forceCreate = true;
_bc.smartSwitchAuthenticateFacebookLimited(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.smartSwitchAuthenticateFacebookLimited(
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
// N/A