How to register an invited user to an app through the Cosync REST API #
Register an invited user account. This function will register a user with the Cosync JWT service with a six digit verification code that was sent to the user email. This call will return a JWT token for the signed up user, an access token for REST calls, and a signed token used by the server to validate the registration.
The signed user token will contain
- handle - user email handle
- code - user signup code
- appId - CosyncJWT application id
- metaData - user metadata if passed
- senderHandle - sender email handle
- senderUserId - sender MongoDB Realm user id
- iat - time at which claim was issued
The metaData is the meta data that was sent as part of invite function call.
This function will fail if the metaData requirements are not met and return a 604. Note, the registering user’s meta data is combined with the metadata set by the inviting user.
This function can be passed an option locale
parameter, which specifies the user’s locale.
URL #
/api/appuser/register
Method #
POST
Headers #
app-token: "<App Token>"
Data Parameter #
{
handle: "<user handle>",
password: "<user password>",
code: "<verification code>"
metaData: "<JSON string of user meta data>"
locale: <"locale for user">
}
Response: #
Success: #
StatusCode: #
200 (OK)
Contents: #
{
"jwt": "<JWT for logged in user>",
"access-token": "<access token for user>":
"signed-user-token": "<signed user token>":
}
Error: #
StatusCode: #
400 (BAD REQUEST)
500 (INTERNAL SERVER ERROR)
Content: #
{
code: "<internal error code>",
message: "<readable error description>"
}
The internal codes are integers:
- 400 - invalid app token
- 401 - app no longer exists
- 402 - app is suspended
- 403 - missing parameter
- 404 - user account is suspended
- 406 - app does not support invite
- 413 - app is migrated
- 500 - internal server error
- 601 - user already registered
- 602 - invalid data
- 604 - invalid metadata
- 609 - invalid locale