Authenticate a user

POST/auth/user

Base URL: https://api.tinkermode.com

Description

Based on the type of the project, this API call does one of the following.

Project Uses the Built-In Account System (Based on Email Addresses)

Authenticate a user by password and return an API key. The request body must contain the email, appId and password parameters. If user account has activated two-factor authentication, the returned object will contain a token to be used in completing authentication process using the /auth/user/auth2F endpoint.

Project Uses the Built-In Account System (Based on Phone Numbers)

Exchange the auth code sent to user via SMS for an API key. The request body must contain the phoneNumber, appId and code parameters.

Project is BYOU ("Bring-Your-Own-Users")

Obtain an API key for a user. The request body must contain the projectId parameter, and either the userId or the externalKey parameter. The request must also come with an Authorization header that contains a Project API Key with the permission to handle BYOU.

Authentication

Send an Authorization header of the form ModeCloud <AUTH_CODE>.

Must contain a Project API Key with BYOU permission. Required for BYOU projects only.

Request body

Content type: application/x-www-form-urlencoded

PropertyTypeRequiredConstraintsDescription
appIdstringNoID of the app being used to access the API. Required except for BYOU projects.
codestringNoAuth code sent to user via SMS. Required only for projects with phone number-based user accounts.
emailstringNoEmail address of user to be authenticated. Required only for projects with email address-based user accounts.
externalKeystringNoExternal key associated with the user to be authenticated. Used only for BYOU projects.
passwordstringNoPassword of user to be authenticated. Required only for projects with email address-based user accounts.
phoneNumberstringNoPhone number of user to be authenticated. Required only for projects with phone number-based user accounts.
projectIdintegerYesID of project to which the user belongs.
userIdintegerNoID of user to be authenticated. Used only for BYOU projects.

Responses

200 User is successfully authenticated, or if the user has activated two-factor authentication, user shall proceed to finish authentication by using the token included in the returned object.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
auth2FTokenstringNoread-only (server-generated)Token used for completing the two-factor authentication process. Token will expire within 3 minutes
expirationTimestringNoread-only (server-generated); format: date-timeThis property is present if token has an expiration time.
sudoerstringNoread-only (server-generated)This property is present if client is authenticated via sudo.
tokenstringNoread-only (server-generated)Access token to be used in the HTTP Authorization header in future API requests.
userIdintegerNoread-only (server-generated)This property is present if token is associated with a user.

401 Authorization is required to access this resource.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.

403 Request failed because of invalid data or denied permission.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.

429 Request failed because of rate limit.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.

500 An unexpected error has occurred.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.

503 The service is temporarily unavailable.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.