# Long lived user access token

If you need a long-lived User access token you can generate one from a short-lived User access token. A long-lived token generally lasts about 60 days.

You will need the following:

* A valid User Access Token
* Your App ID
* Your App Secret

![App id & secret](https://2592634121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT5HLPrqZhkeNGgJP37dC%2Fuploads%2Fc0hbv3XBt1PARCOypPkF%2FScreen%20Shot%202022-07-11%20at%2013.08.55.png?alt=media\&token=77938cca-46a1-461c-a8e2-fa8243cd76f0)

![User access token](https://2592634121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FT5HLPrqZhkeNGgJP37dC%2Fuploads%2FRbBJaTbTQh8N1aY3qesb%2FScreen%20Shot%202022-07-11%20at%2013.12.34.png?alt=media\&token=344672b5-120e-4017-9eda-f9792d0f021d)

<mark style="color:blue;">`GET`</mark> `https://us-central1-appgregator.cloudfunctions.net/instagram/access-token/`

#### Query Parameters

| Name                                                  | Type   | Description                                                                                                                                                                                                                                                                   |
| ----------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name<mark style="color:red;">\*</mark>                | String | ft-4                                                                                                                                                                                                                                                                          |
| client\_id<mark style="color:red;">\*</mark>          | String | 600957674560496                                                                                                                                                                                                                                                               |
| connection\_name<mark style="color:red;">\*</mark>    | String | insta-ft-4                                                                                                                                                                                                                                                                    |
| client\_secret<mark style="color:red;">\*</mark>      | String | 5732d9f01465...                                                                                                                                                                                                                                                               |
| fb\_exchange\_token<mark style="color:red;">\*</mark> | String | EAAIikVy3mZCABAE4V0KBCK84ddzqfgXoCGQ0uJoyqr5LQZBZCC5Rn0VLCwRCpn4XvVLltxMZAEZAyCyVThbnwnaOdHR3GuQYZCQjH4PxHo8lu1amZAr4jvGo9Qyvj8azftV5RPRwPkQZAGxxSjnu9nF56pGIeRA75ZAPjGZCfI77fxTxuj9mmAfvrowvqijMT4BaZBmqFw1tHIaw6iJuiWAsNiSDm17lFxN5PZBvypknZB92R4rbSwiUZCwPHRE82WEm4oEZBgZD |

#### Headers

| Name                                        | Type   | Description                      |
| ------------------------------------------- | ------ | -------------------------------- |
| x-api-key<mark style="color:red;">\*</mark> | String | 43c464439b5507293ba7b315c9875907 |

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

```javascript
{
    "access_token": "EAAIikVy3mZCABAMxVG4bnFssvj5TPUFPaYxI690bVTZBKK6oeuAXiIGTmDN7esIqZCwplXPSsMLPX0vKH60bePt0l33xzBoxaYhIhiafcTMU5hbU6Et9asBUmEnxW51uwRAvDNl1uUOCO6AiG9Hkwz158E7Lra5sTXiokAUD02vjCJwAvQZBW3bYRjFCZBqYZD",
    "token_type": "bearer",
    "expires_in": 5180419
}
```

{% endtab %}
{% endtabs %}

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

```shell
curl --location --request GET 'https://us-central1-appgregator.cloudfunctions.net/instagram/access-token?name=ft-4&connection_name=insta-ft-4&client_id=600957674560496&client_secret=600957674560496|NlYvfu75GsFPT5-i04NgpKxftC4&fb_exchange_token=SHORT-LIVED-USER-ACCESS-TOKEN' \
--header 'x-api-key: U2Fsd...'
```

{% endtab %}

{% tab title="NodeJs - Axios" %}

```javascript
var axios = require('axios');

var config = {
  method: 'get',
  url: 'https://us-central1-appgregator.cloudfunctions.net/instagram/access-token?name=ft-4&connection_name=insta-ft-4&client_id=600957674560496&client_secret=600957674560496|NlYvfu75GsFPT5-i04NgpKxftC4&fb_exchange_token=SHORT-LIVED-USER-ACCESS-TOKEN',
  headers: { 
    'x-api-key': 'U2Fsd...'
  }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

```

{% endtab %}

{% tab title="PHP - cURL" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://us-central1-appgregator.cloudfunctions.net/instagram/access-token?name=ft-4&connection_name=insta-ft-4&client_id=600957674560496&client_secret=600957674560496%7CNlYvfu75GsFPT5-i04NgpKxftC4&fb_exchange_token=SHORT-LIVED-USER-ACCESS-TOKEN',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'x-api-key: U2Fsd...'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}
{% endtabs %}
