AttachUniversalIdentity
Attach a Universal (userid + password) identity to the current profile.
public void FailureCallback(int statusCode, int reasonCode, string statusMessage, object cbObject) {
switch (reasonCode) {
case ReasonCodes.DUPLICATE_IDENTITY_TYPE: { // User is attempting to attach an idenity of the type that exists on there account
// Must get old idenity of type Universal, and detach it first. see GetIdentities
_bc.IdentityService.DetachUniversalIdentity(oldUserId, oldPassword);
// Then, can add a new Identity of that type
_bc.IdentityService.AttachUniversalIdentity(userId, password);
break;
}
case ReasonCodes.MERGE_PROFILES: { // User to attaching a idenity that is connected to a different profile
/**
* Prompt the user that the identity already exists with a different account.
* Ask if they wish to merge the two accounts, and perform a merge if true
*/
_bc.MergeUniversalIdentity(userId, password, true);
break;
}
default: { // Uncaught reasonCode
/**
* Log the unexpected reasonCode to your own internal logs,
* to implement needed error handling later
*/
break;
}
}
}
Service | Operation |
---|---|
identity | ATTACH |
Method Parameters
Parameter | Description |
---|---|
userId | The user's user ID |
password | The user's password |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string userId = "someId";
string password = "someToken";
_bc.IdentityService.AttachUniversalIdentity(
userId,
password,
SuccessCallback, FailureCallback);
const char * userId = "someId";
const char * password = "someToken";
_bc->getIdentityService()->attachUniversalIdentity(
userId, password, this);
- (void)attachUniversalIdentity:(NSString *)userId
authenticationToken:(NSString *)password
completionBlock:(BCCompletionBlock)cb
errorCompletionBlock:(BCErrorCompletionBlock)ecb
cbObject:(BCCallbackObject)cbObject;
public void attachUniversalIdentity(String userId, String password, IServerCallback callback)
_bc.identity.attachUniversalIdentity = function(userId, password, callback)
var userId = "someId";
var password = "password";
ServerResponse result = await _bc.identityService.attachUniversalIdentity(userId:userId, password:password);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
// N/A
// N/A
JSON Response
{
"status": 200,
"data": null
}
Common Error Code
Status Codes
Code | Name | Description |
---|---|---|
40211 | DUPLICATE_IDENTITY_TYPE | Returned when trying to attach an identity type that already exists for that profile. For instance you can have only one Universal identity for a profile. |
40212 | MERGE_PROFILES | Returned when trying to attach an identity type that would result in two profiles being merged into one (for instance an anonymous account and a Universal account). |
550022 | INVALID_PASSWORD_CONTENT | The password doesn't meet the minimum password requirements. |