# Generate Token

### Base URL

```
sdk.faceki.com
```

### Token Generation End Point

```
https://sdk.faceki.com/auth/api/access-token
```

## Token Authentication Postman

**Get a** Bearer Token **access token.**

Authentication for the Faceki API is achieved through token-based authentication. To authenticate requests made to the API, you must include an API token in the **Authorization** of your requests.

For the GET method, the "Authorization" header should include "Bearer Token" followed by your parameters. which are "clientId" and "clientSecret". These parameters help to ensure that the request is valid and authorized.

By including the necessary authentication details in your requests, you can ensure that your requests are processed correctly and securely.

This API is used to generate tokens, this token is client-specific and used to authenticate client identity before performing operations in the system.

{% hint style="info" %}
Method: GET

Authorization: Bearer Token

**Parameter:**

&#x20;clientId  \*(mandatary)

&#x20;clientSecret   \*(mandatory)
{% endhint %}

{% hint style="info" %}

```
Each token will have a token refresh expiry of 5 minutes/ 3600 seconds. 
```

{% endhint %}

{% hint style="info" %}
\*All Params are mandatary required
{% endhint %}

<figure><img src="https://3621714085-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQdiwjdAaMBpDtolO59Ll%2Fuploads%2FHYB1TCY9KvjlPgb2R8gy%2FScreenshot%202023-04-26%20at%203.56.11%20PM.png?alt=media&#x26;token=fccb265d-22d0-4f0b-bb2b-cb768e3cbd01" alt=""><figcaption><p>Choose GET, add End point api, then select Params, add ClientID &#x26; clientSecert</p></figcaption></figure>

<figure><img src="https://3621714085-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQdiwjdAaMBpDtolO59Ll%2Fuploads%2Fuvl3HpQ9OjuvJVyk0sQp%2FScreenshot%202023-04-26%20at%204.04.12%20PM.png?alt=media&#x26;token=128da2d9-52d3-4ae9-9213-f34003d754f4" alt=""><figcaption><p>ClientID and CleintSecert should be selected in Parms</p></figcaption></figure>

<mark style="color:blue;">`GET`</mark> `https://sdk.faceki.com/auth/api/access-token`

#### Headers

| Name                                           | Type   | Description                                                                                                                                                                    |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| clientSecret<mark style="color:red;">\*</mark> | String | <p>clientSecret will be found in the integration section.</p><p> <em>Example: <code>"clientSecret":"00nl0cuq780ur007spqspa94kq6rkn1fap1e0kdre7gdl97lvspk".</code></em><br></p> |
| clientid<mark style="color:red;">\*</mark>     | String | <p>(string, required) Client Id from integration settings.</p><p> <em>Example: <code>"client\_id":"0NTS4CBV8MVII02VGVSPICB00"</code>.</em><br></p>                             |
| Content-Type                                   | String | application/json                                                                                                                                                               |

{% tabs %}
{% tab title="200: OK " %}

```json
    "responseCode": 0,
    "data": {
        "access_token": "eyYkdDhiJuMVdFVFwvYWRPWFBCWTgxaCtTdEpcLytxUFVzSzFGSVlubXhSdUV4UWdJSkU9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiI3YnN2YW5jcGw0dGlvNjA2MDBwbjZobnI1OCIsInRva2VuX3VzZSI6ImFjY2VzcyIsInNjb3BlIjoia3ljXC9hbGwiLCJhdXRoX3RpbWUiOjE2ODI1MTM5NDksImlzcyI6Imh0dHBzOlwvXC9jb2duaXRvLWlkcC5tZS1zb3V0aC0xLmFtYXpvbmF3cy5jb21cL21lLXNvdXRoLTFfNHRvVUVCem9mIiwiZXhwIjoxNjgyNTE3NTQ5LCJpYXQiOjE2ODI1MTM5NDksInZlcnNpb24iOjIsImp0aSI6Ijg2NjY3N2FkLTcyMDctNDFkOC1hZjI5LTk3OWU3MDA3YWViNiIsImNsaWVudF9pZCI6Ijdic3ZhbmNwbDR0aW82MDYwMHBuNmhucjU4In0.NTs5EgFlTlfslPIFZpqK5ABAj7oZMPlGMEvH4YeUHOSB0m7jo_TkzNTHm1GCp32Mz3qCBOHZPiic0PPPCFJ1p1A2o7WSmV4x6GQ9vS55kvOUcgaY0_wS37_2TQ7ObVUeMKAeuSqdE9QBWIiMDdZyslDb-pGlXjC4WE0g30TGbKuu2twungoUztyDS1HqBQUNnZ1T3HV0fOTYXwKmXjGCoP-gZHW3TRG8woF4QnPqoAYItV-aRT01fv2H62NdlL_VZ7A1cCHEClDIs5U5nagGjVWeIxJUTLQT0tFVvYVh6ViCaRCv2hlFcSrSwym0hvtGgPNV0H_eZ2yytoFjq0danQ",
        "expires_in": 3600,
        "token_type": "Bearer"
    }
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
  "status": false,
  "message": "",
  "statusCode": 422,
  "data": {}
}
```

{% endtab %}

{% tab title="402 " %}

```javascript
{
  "clientSecret": ""
}
```

{% endtab %}

{% tab title="403 " %}

```javascript
{
  "status": false,
  "message": "client id is required",
  "statusCode": 422,
  "data": {}
}
```

{% endtab %}
{% endtabs %}

### Response JSON format

<figure><img src="https://3621714085-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQdiwjdAaMBpDtolO59Ll%2Fuploads%2FLAoGg1KekzvjA9hTyewZ%2FScreenshot%202023-04-25%20at%2012.34.31%20PM.png?alt=media&#x26;token=6314aecb-2f96-4bf1-aac5-b97244ec20c1" alt=""><figcaption></figcaption></figure>

Requests return a JSON object with the header:

```
// Content-Type: application/json
```

Responses return JSON with a consistent structure, except downloads.

You must make all your requests to the API over HTTPS and TLS 1.2, with Server Name Indication enabled. Any requests made over HTTP will fail.<br>

## Token authentication Codes <a href="#token-authentication" id="token-authentication"></a>

{% tabs %}
{% tab title="HTTP" %}

```html
Authorization: Token token=<YOUR_API_TOKEN>
```

{% endtab %}

{% tab title="Bash" %}

```
api_url='https://sdk.faceki.com/auth/api/access-token?clientId=7bsvancpl4tio60600pn6hnr58&clientSecret=1d5bssl48phc3vjfh5ljntkl9b2u6a0r80kit6vg08f9kpf70ch9'
curl -X GET $api_url
```

{% endtab %}

{% tab title="PHP" %}

```
$api_url='https://sdk.faceki.com/auth/api/access-token?clientId=00svancpl4tio60600pn6hnr58&clientSecret=0000sl48phc3vjfh5ljntkl9b2u6a0r80kit6vg08f9kpf70ch9';

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $api_url);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($curl);

curl_close($curl);
```

{% endtab %}

{% tab title="Java" %}

```
import requests

api_url = 'https://sdk.faceki.com/auth/api/access-token?clientId=7bsvancpl4tio60600pn6hnr58&clientSecret=1d5bssl48phc3vjfh5ljntkl9b2u6a0r80kit6vg08f9kpf70ch9'

response = requests.get(api_url)

output = response.content

```

{% endtab %}

{% tab title="JavaScript" %}

```
let api_url = 'https://sdk.faceki.com/auth/api/access-token?clientId=7bsvancpl4tio60600pn6hnr58&clientSecret=1d5bssl48phc3vjfh5ljntkl9b2u6a0r80kit6vg08f9kpf70ch9';

fetch(api_url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error(error));

```

This code uses the `fetch` API to make a GET request to the API endpoint and returns a Promise that resolves to the response data. The `console.log` method is used to log the data to the console, and the `console.error` method is used to log any errors that may occur during the request.
{% endtab %}

{% tab title="Ruby" %}

```
require 'net/http'

api_url = URI('https://sdk.faceki.com/auth/api/access-token')
params = { clientId: '7bsvancpl4tio60600pn6hnr58', clientSecret: '1d5bssl48phc3vjfh5ljntkl9b2u6a0r80kit6vg08f9kpf70ch9' }
api_url.query = URI.encode_www_form(params)

response = Net::HTTP.get(api_url)

puts response

```

{% endtab %}

{% tab title="Python" %}

```
api_url = 'https://sdk.faceki.com/auth/api/access-token?clientId=00svancpl4tio60600pn6hnr58&clientSecret=0000sl48phc3vjfh5ljntkl9b2u6a0r80kit6vg08f9kpf70ch9'

import requests

response = requests.get(api_url)
output = response.json()

print(output)
```

{% endtab %}
{% endtabs %}

## Error Code

```
    INTERNAL_SYSTEM_ERROR = 1000,
    SUCCESS = 0,
    NO_RULES_FOR_COMPANY = 7001,
    NEED_REQUIRED_IMAGES = 8001,
    DOCUMENT_VERIFY_FAILED = 8002,
    PLEASE_TRY_AGAIN = 8003,
    FACE_CROPPED = 8004,
    FACE_TOO_CLOSED = 8005,
    FACE_NOT_FOUND = 8006,
    FACE_CLOSED_TO_BORDER = 8007,
    FACE_TOO_SMALL = 8008,
    POOR_LIGHT = 8009,
    ID_VERIFY_FAIL = 8010,
    DL_VERIFY_FAIL = 8011,
    PASSPORT_VERIFY_FAIL = 8012,
    DATA_NOT_FOUND = 8013,
    INVALID_VERIFICATION_LINK = 8014,
    VERIFICATION_LINK_EXPIRED = 8015,
    FAIL_TO_GENERATE_LINK = 8016,
    KYC_VERIFICATION_LIMIT_REACHED = 8017,
    SELFIE_MULTIPLE_FACES = 8018,
    FACE_BLURR = 8019
```

### /kyc-verification
