Adds a new user token for the currently logged in user.
A user token is an identifier that can be used to authenticate a user.
The authentication method depends on the user token. Some tokens support authentication via password, while other user tokens support authentication via a third party provider.
Some of the token_types
are also addressable and can be used to send notifications to a user.
The combination of token
and token_type
is unique because it is used to identify a user.
There can be exactly one user token that is flagged as the default token. If not specified by the user, then this is the first token that was associated with the user object. The default token is used to send notifications if no specific token is selected.
Content-Type: application/json
App-Id: {app_id}
Name | Type | Description |
---|---|---|
token | string | The value of the token, for example john.doe@example.com |
token_type
*
| string | The type of the token, for example email. |
is_primary | boolean | Flag to indicate if this token is the primary token. |
auth_data | object | Contains the data that is used for authentiation. |
{
"token": "1234567",
"token_type": "facebook",
"is_primary": false,
"auth_data": {
"code": "CAAKufIJSLC0BAEyrQkyFsCb2ziiwa...."
}
}
After a successful creation, the full user token object is returned.
Error | Type | Description |
---|---|---|
200 | http | Everything is OK |
400 | http | Bad Request |
403 | http | Not Authorized |
409 | http | The token is already in use |
Name | Type | Description |
---|---|---|
id | string | The token's unique identifier, a 36 character UUID. |
meta | object | The object's meta information (for example the creation timestamp). |
properties | object | The properties of the object. |
Name | Type | Description |
---|---|---|
user_id | string | Unique identifier of the user object that is referenced by the token. |
app_id | string | Unique identifier of the application object that created the user. |
token_type | string | The type of the token, for example
email
. |
token | string | The value of the token, for example
john.doe@example.com
. |
confirmed | boolean | Flag to indicate if the token is confirmed, for example after the user clicked a verification link in an email. |
is_primary | boolean | Flag to indicate if this token is the primary token. The primary token is used when no other token is explicitly selected, for example to send messages. This will automatically set the
is_primary
flag of an existing token to
false
, because only one token can be the primary token. |
{
"payload": {
"id": "29828993-c2b4-4f6b-a289-f4bdd965d069",
"meta": {
"data_type": "blockv::token",
"when_created": "2018-01-01T00:00:00+00:00",
"when_modified": "2018-01-01T00:00:00+00:00"
},
"properties": {
"user_id": "001d0933-88e6-4e17-b147-0f672dc016d1",
"app_id": "ebd04065-41d3-4e30-9844-44c594f6b17f",
"token_type": "email",
"token": "new.email@example.com",
"confirmed": false,
"is_primary": false
}
}
}