# Access Tokens

## Authentication <a href="#authentication" id="authentication"></a>

### Access Tokens <a href="#access_token" id="access_token"></a>

The Oauth2 service generates access tokens for authenticated users, applications or companies. The token returned in the Oauth2 response can be used to access protected resources on Turium Enigma services.

The Oauth2 response can, depending on grant type contain these values:

<table data-full-width="true"><thead><tr><th>Name</th><th>Type</th><th>Format</th><th>Description</th></tr></thead><tbody><tr><td><code>expires_in</code></td><td><code>string</code></td><td>-</td><td>The lifetime in seconds of the access token</td></tr><tr><td><code>scope</code></td><td><code>string</code></td><td>-</td><td>The scope of the access token as granted to the client application</td></tr><tr><td><code>token_type</code></td><td><code>string</code></td><td>-</td><td>The type of token returned. Value will be <code>Bearer</code></td></tr><tr><td><code>access_token</code></td><td><code>string</code></td><td>-</td><td>Token used to access protected resources of Turium Enigma services.</td></tr><tr><td><code>refresh_token</code></td><td><code>string</code></td><td>-</td><td>Refresh token required to request a new access token for a given user.</td></tr><tr><td><code>geolocation</code></td><td><code>string</code></td><td>-</td><td>The base URL for where the user profile lives. </td></tr><tr><td><code>id_token</code></td><td><code>string</code></td><td>-</td><td>The OIDC Token in the JSON Web Token (JWT) format that describes the user or company</td></tr></tbody></table>

**Token Response**

```
HTTP/1.1 200 OK
Content-Type: application/json
Date: date-requested
Content-Length: 3397
Connection: Close
```

```
{
  "expires_in": "3600",
  "scope": "app-scopes",
  "token_type": "Bearer",
  "access_token": "access_token",
  "refresh_token": "refresh_token",
  "id_token": "oidc_token"
}
```

### Obtaining a token <a href="#obtain_token" id="obtain_token"></a>

You can obtain a token for three different types of principals in the Turium Enigma universe.

* User
* Application
* Company

**Token Lifetime**

An `accessToken` has a one hour lifetime.

In order to obtain a token, the client application needs to call the Oauth2 endpoint using various grants depending on the authentication scenarios required.&#x20;

### Refreshing a token <a href="#refresh_token" id="refresh_token"></a>

The refresh grant is used to refresh an access\_token that has expired. This grant can be used anytime a refresh\_token is returned in the response of another grant request. No user interaction is required.

**Token Lifetime**

A refresh token has a **six month** lifetime. If the refresh token expires, the client application must reinitiate the authorization process. When a refresh token is used to request a new access token, both a new access token as well as a new refresh token are returned in the response. This token can change even if most of the time, this value is the same. Client applications should treat all returned refresh tokens as new tokens and overwrite the stored tokens with the new token from the response.

It is recommended that the client application use the refresh grant to request a new access token as the initial step of accessing protected resources of Turium Enigma services.

**Refreshing the token**

To request a new access token using a valid refresh token, use the Oauth2 /token endpoint. Use the `application/x-www-form-urlencoded` content type.

```
POST /oauth2/v0/token
```

**Post Body**

<table data-full-width="true"><thead><tr><th>Name</th><th>Type</th><th>Format</th><th>Description</th></tr></thead><tbody><tr><td><code>client_id</code></td><td><code>string</code></td><td><code>UUID</code></td><td><strong>Required</strong> The client applications client_id supplied by App Management</td></tr><tr><td><code>client_secret</code></td><td><code>string</code></td><td><code>UUID</code></td><td><strong>Required</strong> The client applications client_secret supplied by App Management</td></tr><tr><td><code>refresh_token</code></td><td><code>string</code></td><td>-</td><td><strong>Required</strong> An existing valid refresh token to be used to request a new access token</td></tr><tr><td><code>scope</code></td><td><code>string</code></td><td>-</td><td><strong>Optional</strong> The client applications list of scopes</td></tr><tr><td><code>grant_type</code></td><td><code>string</code></td><td>-</td><td><strong>Required</strong> The grant type instructs the Oauth2 service how to process the request. For refresh token, the value must be <code>refresh_token</code></td></tr></tbody></table>

**Request**

```
POST /oauth2/v0/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Connection: close
Content-Length: 437

POST BODY
client_id=your-client_id
&client_secret=your-client_secret
&grant_type=refresh_token
&refresh_token=valid-refresh_token
&scope=app-scope
```

**Response**

```
HTTP/1.1 200 OK
Content-Type: application/json
Date: date-requested
Content-Length: 3397
Connection: Close
```

```
{
  "expires_in": "3600",
  "scope": "app-scopes",
  "token_type": "Bearer",
  "access_token": "access_token",
  "refresh_token": "refresh_token",
  "id_token": "oidc_token"
}
```

When the token has been refreshed, store the geolocation and the refresh token as they may have changed. On subsequent calls, use the last received geolocation and refresh token.

### Revoking a token <a href="#revoke_token" id="revoke_token"></a>

All refresh tokens associated to a user for an application can be revoked by calling the endpoint with a `DELETE` action. You have to provide the User’s `accessToken` in the Authorization Header as `Authorization: Bearer <access_token>`.

**Request**

```
DELETE 
Authorization: Bearer {token}
```

**Response**

```
HTTP/1.1 200 OK
```

### Managing tokens <a href="#manage_token" id="manage_token"></a>

Refresh Tokens are strings that allow your application to obtain a fresh `accessToken` on behalf of a user to access Turium Enigma APIs. The exact format of the string can change, but may look similar to the following:

```
e013335d-b4ce-4c43-a7e4-b67abc1adcb0
```

or like this:

```
2d725xipty0z7ha3vlpy8b2c3hqxmw
```

It is highly recommended that you store Refresh Tokens together with your user’s authorization metadata in your application every time you obtain a new `refreshToken` as they might change depending on different scenarios.

FOR APP CENTER AND SUPPLIER PARTNERS supporting all geolocations, storing the authorization metadata, including the geolocation are REQUIRED.

### Base URIs <a href="#base_uri" id="base_uri"></a>

When making API calls, the appropriate base URI should be used. There are three different scenarios:

1. Obtaining a token for a user.
2. Refreshing a token.
3. Calling other APIs.

The base URI for obtaining a token will leverage your application’s geolocation. The base URI for refreshing tokens and all other API calls will leverage the token’s geolocation.

#### Base URIs for Obtaining a Token <a href="#base_uri_obtain_token" id="base_uri_obtain_token"></a>

When your application is created, you will be provided with a client ID, secret and geolocation. When obtaining a token, your application should use the base URI for the geolocation in which your application exists.

There are two endpoints for each geolocation - one is the default (used for server-side calls) and the other should be used for client-side calls.

> **When obtaining the token, the token’s geolocation will be included in the response. The token’s geolocation should be stored along with the token. The Developer’s app will then be able to make subsequent calls using the token and the correct end points based on the token’s GEO location.**

#### Base URIs for All Other Calls <a href="#base-uris-for-all-other-calls" id="base-uris-for-all-other-calls"></a>

When refreshing a token or when calling any other APIs, the token’s geolocation should be used as the base URI.

**Note:** Client-side calls should use the www- variant of the base URI.

**Example**

Consider an example where your application obtains a token and receives the response below:

```
HTTP/1.1 200 OK
Content-Type: application/json
Date: date-requested
Content-Length: 3397
Connection: Close
```

```
{
  "expires_in": "3600",
  "scope": "app-scopes",
  "token_type": "Bearer",
  "access_token": "access_token",
  "refresh_token": "refresh_token",
  "id_token": "oidc_token"
}
```

When your application calls another API, such as the receipts API to post a receipt, the request should be made using the base URI specified in the geolocation value of the response. The geolocation value can be any of the supported base URIs. The application should store the specific geolocation it receives, and use it as the base URI for future API calls when using that token.

### ID Token <a href="#id_token" id="id_token"></a>

Authentication service will return an OPENID compatible ID token with every token request. This `id_token` is primarily used to describe information about a user or a company. You can obtain the userId from this token.

#### Verifying an id\_token <a href="#verifying-an-id_token" id="verifying-an-id_token"></a>

The Authentication service exposes JWKs that can be used to validate the id\_token in the form of a JWT. Validating a JWT is described in detail in RFC 7519 - sec 7.2

### Authorization grant <a href="#auth_grant" id="auth_grant"></a>

The authorization grant is the regular 3-legged oauth2 grant and is defined in detail in RFC6749 sec-4.1. This grant requires the user to explicitly authenticate themselves and authorise the application initiating the grant.

The users *must be* able to authenticate themselves via a Turium Enigma username & password. Users will be challenged to login by an Oauth2 HTML page.

**Who should use it**

* 3rd party “partner” websites - or -
* non-Turium Enigma Applications - & -
* Applications that need explicit user authentication & authorization - & -
* Applications that can securely store a code, access\_token & refresh\_token

**Grant details**

> Note that the grant type must be accessed using the `www-` version of the API Gateway in order to avoid certificate issues with some browsers.&#x20;

`GET /oauth2/v0/authorize`

<table data-full-width="true"><thead><tr><th>Name</th><th>Type</th><th>Format</th><th>Description</th></tr></thead><tbody><tr><td><code>client_id</code></td><td><code>string</code></td><td><code>UUID</code></td><td>Applications client_id supplied by App Management</td></tr><tr><td><code>redirect_uri</code></td><td><code>string</code></td><td>-</td><td>The redirect URI for your application to continue with the Oauth2 flow</td></tr><tr><td><code>scope</code></td><td><code>string</code></td><td>-</td><td>List of scopes that application is asking for</td></tr><tr><td><code>response_type</code></td><td><code>string</code></td><td>-</td><td><code>code</code></td></tr><tr><td><code>state</code></td><td><code>string</code></td><td>-</td><td> </td></tr></tbody></table>

With this grant, the user has two authentication options:

1. Username and password
2. One-time link using a verified email address

With both options, once the user is successfully authenticated and the user authorizes your application, the user will be redirected to the redirect\_URI specified in the initial /authorize call with a temporary token appended.

`<redirect_uri>?geolocation=<token_geolocation>&code=<token>`

*If the user is not successfully authenticated or does not authorize the scopes for your application, an error code and description will be appended to the redirect URI.*&#x20;

Your application must then exchange the temporary token for a long-lived token using the below.

`POST /oauth2/v0/token`

<table data-full-width="true"><thead><tr><th>Name</th><th>Type</th><th>Format</th><th>Description</th></tr></thead><tbody><tr><td><code>client_id</code></td><td><code>string</code></td><td><code>UUID</code></td><td>Applications client_id supplied by App Management</td></tr><tr><td><code>client_secret</code></td><td><code>string</code></td><td><code>UUID</code></td><td>Applications client_secret supplied by App Management</td></tr><tr><td><code>redirect_uri</code></td><td><code>string</code></td><td>-</td><td>The redirect_uri that is registered for the application</td></tr><tr><td><code>code</code></td><td><code>string</code></td><td><code>UUID</code></td><td>The authorization code provided by Auth</td></tr><tr><td><code>grant_type</code></td><td><code>string</code></td><td>-</td><td><code>authorization_code</code></td></tr></tbody></table>

### Password grant <a href="#password_grant" id="password_grant"></a>

The Password grant can be used when there is a trust relationship between the user and the application. There are two credential types allowed with Password Grant:

1. “Password”: with this credential type, the application either already has the user’s credentials or can obtain the user’s credentials by directly interacting with the user.
2. “AuthToken”: This credential type is used for connections.&#x20;

**Post Body**

<table data-full-width="true"><thead><tr><th>Name</th><th>Type</th><th>Format</th><th>Description</th></tr></thead><tbody><tr><td><code>client_id</code></td><td><code>string</code></td><td><code>UUID</code></td><td>Applications client_id supplied by App Management</td></tr><tr><td><code>client_secret</code></td><td><code>string</code></td><td><code>UUID</code></td><td>Applications client_secret supplied by App Management</td></tr><tr><td><code>grant_type</code></td><td><code>string</code></td><td>-</td><td>Specify which grant type you expect the oauth2 service to process. for password grant, the value is <code>password</code></td></tr><tr><td><code>username</code></td><td><code>string</code></td><td>-</td><td>specify the username or userId</td></tr><tr><td><code>password</code></td><td><code>string</code></td><td>-</td><td>specify the user’s password</td></tr><tr><td><code>credtype</code></td><td><code>string</code></td><td>-</td><td>The credtype signifies to oauth2 which credential set is being submitted in the request. There are two supported values: <code>authtoken</code> and <code>password</code>. For connections from the App Center, use <code>authtoken</code>. if omitted, oauth2 will assume the type is <code>password</code>.</td></tr></tbody></table>

**Request**

```
POST /oauth2/v0/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Connection: close
Content-Length: 175

POST BODY
client_id=your-client_id
&client_secret=your-client_secret
&grant_type=password
&username=username
&password=password
```

**Response**

```
HTTP/1.1 200 OK
Content-Type: application/json
Date: date-requested
Content-Length: 3397
Connection: Close
```

```
{
  "expires_in": "3600",
  "scope": "app-scopes",
  "token_type": "Bearer",
  "access_token": "access_token",
  "refresh_token": "refresh_token",
  "id_token": "oidc_token"
}
```

example bad login

```
{
  "error": "invalid_grant",
  "error_description": "Incorrect Credentials. Please Retry",
  "code": 5
}
```

### Client Credentials grant <a href="#client_credentials" id="client_credentials"></a>

Use the `application/x-www-form-urlencoded` content type.

`POST /oauth2/v0/token`

**Post Body**

<table data-full-width="true"><thead><tr><th>Name</th><th>Type</th><th>Format</th><th>Description</th></tr></thead><tbody><tr><td><code>client_id</code></td><td><code>string</code></td><td><code>UUID</code></td><td><strong>Required</strong> Applications client_id supplied by App Management</td></tr><tr><td><code>client_secret</code></td><td><code>string</code></td><td><code>UUID</code></td><td><strong>Required</strong> Applications client_secret supplied by App Management</td></tr><tr><td><code>grant_type</code></td><td><code>string</code></td><td>-</td><td><strong>Required</strong> Specify which grant type you expect the oauth2 service to process. For client_credentials grant, the value is <code>client_credentials</code></td></tr></tbody></table>

**Request**

```
POST /oauth2/v0/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Connection: close
Content-Length: 127

POST BODY
client_id=your-client_id
&client_secret=your-client_secret
&grant_type=client_credentials
```

**Response**

```
HTTP/1.1 200 OK
Content-Type: application/json
Date: date-requested
Content-Length: 1626
Connection: Close
```

```
{
  "expires_in": "3600",
  "scope": "app-scopes",
  "token_type": "Bearer",
  "access_token": "access_token"
}
```

### One Time Password grant <a href="#otp_grant" id="otp_grant"></a>

The One-time Password grant type leverages email, phone (text messaging), instant messaging and similar systems to provide per user access tokens to client applications. This grant type requires the following steps:

1. The calling application calls the OAuth2 service specifying the otp grant type along with required parameters.
2. The OAuth2 service generates a one time token which it sends through the messaging mechanism chosen by the application.
3. The user retrieves the token and presents it to the application. The means of having this presented to the application is the responsibility of the application.
4. The application presents this one-time token to the OAuth2 service via the token endpoint.

**Request a one-time token to be sent to the user**

Use the `application/x-www-form-urlencoded` content type.

`POST /oauth2/v0/otp`

**Post Body**

<table data-full-width="true"><thead><tr><th>Name</th><th>Type</th><th>Format</th><th>Description</th></tr></thead><tbody><tr><td><code>client_id</code></td><td><code>string</code></td><td><code>UUID</code></td><td><strong>Required</strong> The client_id as defined in the Turium Enigma application management system.</td></tr><tr><td><code>client_secret</code></td><td><code>string</code></td><td><code>UUID</code></td><td><strong>Required</strong> The client_secret as set by the client owner in the Turium Enigma application management system.</td></tr><tr><td><code>channel_handle</code></td><td><code>string</code></td><td>-</td><td><strong>Required</strong> The location (email address, phone number) where the one time token should be sent. Currently, only <code>email address</code> is valid.</td></tr><tr><td><code>channel_type</code></td><td><code>string</code></td><td>-</td><td><strong>Required</strong> The type of messaging system to use. Currently only <code>email</code> is valid</td></tr><tr><td><code>name</code></td><td><code>string</code></td><td>-</td><td><em>Optional</em> The name of the user that appears in the email.</td></tr><tr><td><code>company</code></td><td><code>string</code></td><td>-</td><td><em>Optional</em> The company or application name that appears in the email.</td></tr><tr><td><code>link</code></td><td><code>string</code></td><td>-</td><td><em>Optional</em> The callback URL that appears in the email for users to click to complete the auth flow.</td></tr></tbody></table>

The calling application code can also append n-number of unique client defined parameters in the URI for the purpose of connecting the one time token to the application when received by the user. The names of these parameters cannot conflict with the API defined parameters.

The following are reserved words and cannot be used as client application defined parameters:

```
/otp: "client_id" "client_secret" "channel_type" "channel_handle"
```

```
/token: "client_id" "client_secret" "channel_type" "channel_handle" "scope" "grant_type" "otp"
```

If the calling application chooses to send custom parameters, all of these exact same parameters *must be* included in subsequent API calls to acquire the access token. In other words, the URI signature, modulo the one time token parameter itself and token service specific parameters, *must match* the originating URI signature.

**Request**

```
POST /oauth2/v0/otp HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Accept: application/json
Connection: close
Content-Length: 437

POST BODY
client_id=your-client_id
&client_secret=your-client_secret
&channel_handle=email adress
&channel_type=valid-email
&link=https://example.com/callback
```

**Response**

```
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 22
Date: date-requested
```

```
{
  "message": "otp sent"
}
```

**Request an access token**

The One Time Password grant requires that all of the parameters, including client application defined parameters to be sent in the request body when requesting an access token. Use the `application/x-www-form-urlencoded` content type.

`POST oauth2/v0/token`

**Post Body**

<table data-full-width="true"><thead><tr><th>Name</th><th>Type</th><th>Format</th><th>Description</th></tr></thead><tbody><tr><td><code>client_id</code></td><td><code>string</code></td><td><code>UUID</code></td><td><strong>Required</strong> The client_id as defined in the Turium Enigma application management system.</td></tr><tr><td><code>client_secret</code></td><td><code>string</code></td><td><code>UUID</code></td><td><strong>Required</strong> The client_secret as set by the client owner in the Turium Enigma application management system.</td></tr><tr><td><code>channel_handle</code></td><td><code>string</code></td><td>-</td><td><strong>Required</strong> The location (email address, phone number) where the one time token should be sent.</td></tr><tr><td><code>channel_type</code></td><td><code>string</code></td><td>-</td><td><strong>Required</strong> The type of messaging system to use. Currently only <code>email</code> is valid</td></tr><tr><td><code>scope</code></td><td><code>string</code></td><td>-</td><td>The scope(s) requested by the client for the token.</td></tr><tr><td><code>grant_type</code></td><td><code>string</code></td><td>-</td><td><strong>Required</strong> The grant type being used, specifically for this approach: <code>otp</code>.</td></tr><tr><td><code>otp</code></td><td><code>string</code></td><td>-</td><td><strong>Required</strong> The one-time token provided as a result of the <strong>Send a one time token to the user</strong> method.</td></tr></tbody></table>

**Request**

```
POST /oauth2/v0/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Connection: close
Content-Length: 437

POST BODY
client_id=your-client_id
&client_secret=your-client_secret
&channel_handle=email adress
&channel_type=valid-email
&scope=app_scope
&grant_type=otp
&otp=one-time-token
```

**Response**

```
HTTP/1.1 200 OK
Date: date-requested
Content-Length: 1490
Connection: keep-alive
```

```
{
  "expires_in": "3600",
  "scope": "app-scopes",
  "token_type": "Bearer",
  "access_token": "access_token",
  "refresh_token": "refresh_token",
  "id_token": "oidc_token"
}
```

### Response Codes <a href="#response_codes" id="response_codes"></a>

**HTTP Status returned by oauth2**

<table data-full-width="true"><thead><tr><th>HTTP Status</th><th>Description</th></tr></thead><tbody><tr><td>200</td><td>OK - Successful call, response is in body.</td></tr><tr><td>400</td><td>Bad Request <code>(error, error_description, code)</code></td></tr><tr><td>401</td><td>Unauthorized <code>(error, error_description, code)</code></td></tr><tr><td>403</td><td>Forbidden <code>(error, error_description, code)</code></td></tr><tr><td>404</td><td>Not Found <code>(error, error_description, code)</code></td></tr><tr><td>500</td><td>Server Error, error message is in body.</td></tr><tr><td>503</td><td>Server Timed Out, error message is in body.</td></tr></tbody></table>

4xx class errors have a JSON response with the following fields

```
{
  "code": <number>,
  "error": <error>,
  "error_description": <error_description>,
  "geolocation": <geolocation url where user lives>
}
```

**/authorize**

If the authorization or authentication are unsuccessful, your application will receive an error code and description at the redirect\_uri provided.

```Your_Redirect_Uri
 error_code=<>
 &error_description=<>
```

In all cases, the friendly error description should be displayed to the user.

**/token**

<table data-full-width="true"><thead><tr><th>Code</th><th>Error</th><th>Description</th></tr></thead><tbody><tr><td>5</td><td><code>invalid_grant</code></td><td>Incorrect credentials. Please Retry</td></tr><tr><td>10</td><td><code>invalid_grant</code></td><td>Account is disabled. Please contact support</td></tr><tr><td>11</td><td><code>invalid_grant</code></td><td>Account is disabled. Please contact support</td></tr><tr><td>12</td><td><code>invalid_grant</code></td><td>Logon Denied. Please contact support</td></tr><tr><td>13</td><td><code>invalid_grant</code></td><td>Logon Denied. Please contact support</td></tr><tr><td>14</td><td><code>invalid_grant</code></td><td>Account Locked. Please contact support</td></tr><tr><td>16</td><td><code>invalid_request</code></td><td>user lives elsewhere</td></tr><tr><td>19</td><td><code>invalid_grant</code></td><td>Incorrect credentials. Please Retry</td></tr><tr><td>20</td><td><code>invalid_grant</code></td><td>Logon Denied. Please contact support (typically due to IP restriction)</td></tr><tr><td>51</td><td><code>invalid_request</code></td><td>username was not supplied</td></tr><tr><td>52</td><td><code>invalid_request</code></td><td>password was not supplied</td></tr><tr><td>53</td><td><code>invalid_client</code></td><td>company is not enabled for this client</td></tr><tr><td>54</td><td><code>invalid_scope</code></td><td>requested scope exceeds granted scope</td></tr><tr><td>55</td><td><code>invalid_request</code></td><td>we don’t know this email</td></tr><tr><td>56</td><td><code>invalid_request</code></td><td><code>otp</code> was not supplied</td></tr><tr><td>57</td><td><code>invalid_request</code></td><td><code>channel_type</code> missing</td></tr><tr><td>58</td><td><code>invalid_request</code></td><td><code>channel_handle</code> missing</td></tr><tr><td>59</td><td><code>access_denied</code></td><td>client disabled</td></tr><tr><td>60</td><td><code>invalid_grant</code></td><td>these are not the grants you are looking for</td></tr><tr><td>61</td><td><code>invalid_client</code></td><td>client not found</td></tr><tr><td>62</td><td><code>invalid_request</code></td><td><code>client_id</code> was not supplied</td></tr><tr><td>63</td><td><code>invalid_request</code></td><td><code>client_secret</code> was not supplied</td></tr><tr><td>64</td><td><code>invalid_client</code></td><td>Incorrect credentials. Please Retry</td></tr><tr><td>65</td><td><code>invalid_request</code></td><td><code>grant_type</code> was not supplied</td></tr><tr><td>80</td><td><code>invalid_request</code></td><td>invalid channel type</td></tr><tr><td>81</td><td><code>invalid_request</code></td><td>bad channel handle</td></tr><tr><td>83</td><td><code>invalid_request</code></td><td>otp not found</td></tr><tr><td>84</td><td><code>invalid_request</code></td><td>fact verification failed</td></tr><tr><td>85</td><td><code>invalid_request</code></td><td>otp verification failed</td></tr><tr><td>100</td><td><code>invalid_request</code></td><td>backend does not know about this username</td></tr><tr><td>101</td><td><code>invalid_request</code></td><td>code was not supplied</td></tr><tr><td>102</td><td><code>invalid_request</code></td><td><code>redirect_uri</code> was not supplied</td></tr><tr><td>103</td><td><code>invalid_request</code></td><td>code is bad or expired</td></tr><tr><td>104</td><td><code>invalid_grant</code></td><td><code>redirect_uri</code> does not match the previous grant</td></tr><tr><td>105</td><td><code>invalid_grant</code></td><td>this grant was not issued to you!</td></tr><tr><td>106</td><td><code>invalid_request</code></td><td><code>refresh_token</code> was not supplied</td></tr><tr><td>107</td><td><code>invalid_request</code></td><td>refresh disallowed for app</td></tr><tr><td>108</td><td><code>invalid_grant</code></td><td>bad or expired refresh token</td></tr><tr><td>109</td><td><code>invalid_request</code></td><td><code>loginid</code> was not supplied</td></tr><tr><td>115</td><td><code>invalid_request</code></td><td>unauthenticated client will not be issued token!</td></tr><tr><td>117</td><td><code>invalid_request</code></td><td>nonce is mandatory for this <code>response_type</code></td></tr><tr><td>118</td><td><code>invalid_request</code></td><td>display is invalid</td></tr><tr><td>119</td><td><code>invalid_request</code></td><td>prompt is invalid</td></tr><tr><td>119</td><td><code>invalid_request</code></td><td>prompt must be set to consent for <code>offline_access</code></td></tr><tr><td>120</td><td><code>invalid_request</code></td><td><code>credtype</code> is invalid</td></tr><tr><td>121</td><td><code>invalid_request</code></td><td><code>login_type</code> is invalid</td></tr><tr><td>122</td><td><code>invalid_request</code></td><td>proxies supplied are invalid</td></tr><tr><td>123</td><td><code>invalid_request</code></td><td>principal is disabled</td></tr><tr><td>134</td><td><code>invalid_request</code></td><td>Company undergoing scheduled maintenance.</td></tr></tbody></table>

**/otp**

<table data-full-width="true"><thead><tr><th>Code</th><th>Error</th><th>Description</th></tr></thead><tbody><tr><td>16</td><td><code>invalid_request</code></td><td>user lives elsewhere</td></tr><tr><td>57</td><td><code>invalid_request</code></td><td><code>channel_type</code> was not supplied</td></tr><tr><td>58</td><td><code>invalid_request</code></td><td><code>channel_handle</code> was not supplied</td></tr><tr><td>60</td><td><code>invalid_grant</code></td><td>these are not the grants you are looking for</td></tr><tr><td>61</td><td><code>invalid_client</code></td><td><code>client_id</code> is not known to us</td></tr><tr><td>62</td><td><code>invalid_request</code></td><td><code>client_id</code> was not supplied</td></tr><tr><td>63</td><td><code>invalid_request</code></td><td><code>client_secret</code> was not supplied</td></tr><tr><td>80</td><td><code>invalid_request</code></td><td>invalid channel type</td></tr><tr><td>81</td><td><code>invalid_request</code></td><td>bad channel handle</td></tr><tr><td>82</td><td><code>invalid_request</code></td><td>the number of open otp requests has been exceeded</td></tr></tbody></table>

### Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

In order to assist with troubleshooting, Turium Enigma responds with a unique correlationId in the response header. The key to look for is `correlationid`. This unique code can be used during troubleshooting as it identifies the API call in the log files. You should record this information in your own API call logs as well so that you can pass this information on to the Turium Enigma support team.

Example of the `correlationid` in the response:

```
< HTTP/1.1 200 OK
< Server: cnqr-papeete
< Date: Mon, 04 Dec 2017 22:07:05 GMT
< Content-Type: application/json
< Content-Length: 2897
< Connection: keep-alive
< Correlationid: 2803b8f8-a42b-43c2-a739-b8768e4759b8
```
