AttachEmailIdentity
Attach a Email and Password identity to the current profile.
Error Handling Example
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 Email, and detach it first. see GetIdentities
_bc.IdentityService.DetachEmailIdentity(oldEmail, oldPassword);
// Then, can add a new Identity of that type
_bc.IdentityService.AttachEmailIdentity(email, 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.MergeEmailIdentity(email, 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 |
---|---|
The user's e-mail address | |
password | The user's password |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string email = "email@domain.com";
string password = "somePassword";
_bc.IdentityService.AttachEmailIdentity(
email,
password,
SuccessCallback, FailureCallback);
const char * email = "email@domain.com";
const char * password = "someToken";
_bc->getIdentityService()->attachEmailIdentity(
email, password, this);
- (void)attachEmailIdentity:(NSString *)email
authenticationToken:(NSString *)password
completionBlock:(BCCompletionBlock)cb
errorCompletionBlock:(BCErrorCompletionBlock)ecb
cbObject:(BCCallbackObject)cbObject;
public void attachEmailIdentity(String email, String password, IServerCallback callback)
_bc.identity.attachEmailIdentity = function(email, password, callback)
var email = "email@domain.com";
var password = "somePassword";
ServerResponse result = await _bc.identityService.attachEmailIdentity(email:email, 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 Email 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 Email account). |
40221 | EMAIL_NOT_VALID | The provided email address is not in the correct format. |
550022 | INVALID_PASSWORD_CONTENT | The password doesn't meet the minimum password requirements. |