# Getting Access Tokens from Social Login Providers

## Get a List of Access Tokens from All Social Logins for a User

<mark style="color:blue;">`GET`</mark> `https://www.cotter.app/api/v0/oauth/token/list/:cotter_user_id`

This will give you a list of access tokens that the user has for each social login provider that is associated with their account.

#### Path Parameters

| Name             | Type   | Description               |
| ---------------- | ------ | ------------------------- |
| cotter\_user\_id | string | The user's Cotter User ID |

#### Headers

| Name             | Type   | Description         |
| ---------------- | ------ | ------------------- |
| API\_KEY\_ID     | string | Your API Key ID     |
| API\_SECRET\_KEY | string | Your API Secret Key |

{% tabs %}
{% tab title="200 A list of OAuth Tokens from each provider that is associated with the user. " %}

```javascript
[
  {
    "ID": "abcdefgh-abcd-abcd-abcd-24339e5457ff",  // OAuth Token ID
    "created_at": "2020-09-04T04:51:10.778976Z",
    "updated_at": "2020-09-04T04:51:10.778977Z",
    "deleted_at": "0001-01-01T00:00:00Z",
    "company_id": "abcdefgh-abcd-abcd-abcd-f901315ad31b",  // Your API KEY ID
    "user_id": "abcdefgh-abcd-abcd-abcd-22bc178867ef",     // The user's ID
    "provider_user_id": "20483939",                        // User ID from the Provider (Github User ID)
    "provider_username": "putrikarunia",                   // Login/username from the provider (Github Username)
    "identity_provider": "GITHUB",
    "tokens": {                      // OAuth tokens returned by the provider
      "access_token": "abcdefghabcdefghabcdefghabcdefghabcdefg",
      "scope": "repo,user",
      "token_type": "bearer"
    }
  },
  {
    "ID": "abcdefgh-abcd-abcd-abcd-24339e5457ff",  // OAuth Token ID
    "created_at": "2020-09-04T04:51:10.778976Z",
    "updated_at": "2020-09-04T04:51:10.778977Z",
    "deleted_at": "0001-01-01T00:00:00Z",
    "company_id": "abcdefgh-abcd-abcd-abcd-f901315ad31b",  // Your API KEY ID
    "user_id": "abcdefgh-abcd-abcd-abcd-22bc178867ef",     // The user's ID
    "provider_user_id": "20483939",                        // User ID from the Provider (Github User ID)
    "provider_username": "putrikarunia",                   // Login/username from the provider (Github Username)
    "identity_provider": "GOOGLE",
    "tokens": {                      // OAuth tokens returned by the provider
      "access_token": "abcdefghabcdefghabcdefghabcdefghabcdefgh",
      "scope": "repo,user",
      "token_type": "bearer"
    }
  },
  ...
]
```

{% endtab %}
{% endtabs %}

## Get an Access Token from a Specific Provider for a User

<mark style="color:blue;">`GET`</mark> `https://www.cotter.app/api/v0/oauth/token/:provider_name/:cotter_user_id`

Get an access token from one provider for the user.

#### Path Parameters

| Name             | Type   | Description               |
| ---------------- | ------ | ------------------------- |
| cotter\_user\_id | string | The user's Cotter User ID |
| provider\_name   | string | One of: `GITHUB`          |

#### Headers

| Name             | Type   | Description         |
| ---------------- | ------ | ------------------- |
| API\_KEY\_ID     | string | Your API Key ID     |
| API\_SECRET\_KEY | string | Your API Secret Key |

{% tabs %}
{% tab title="200 A Token Object with the OAuth tokens from the provider for the user." %}

```javascript
{
  "ID": "abcdefgh-abcd-abcd-abcd-24339e5457ff",  // OAuth Token ID
  "created_at": "2020-09-04T04:51:10.778976Z",
  "updated_at": "2020-09-04T04:51:10.778977Z",
  "deleted_at": "0001-01-01T00:00:00Z",
  "company_id": "abcdefgh-abcd-abcd-abcd-f901315ad31b",  // Your API KEY ID
  "user_id": "abcdefgh-abcd-abcd-abcd-22bc178867ef",     // The user's ID
  "provider_user_id": "20483939",                        // User ID from the Provider (Github User ID)
  "provider_username": "putrikarunia",                   // Login/username from the provider (Github Username)
  "identity_provider": "GITHUB",
  "tokens": {                      // OAuth tokens returned by the provider
    "access_token": "abcdefghabcdefghabcdefghabcdefghabcdefg",
    "scope": "repo,user",
    "token_type": "bearer"
  }
}
```

{% endtab %}
{% endtabs %}

## Delete an Access Token from a Specific Provider for a User

<mark style="color:red;">`DELETE`</mark> `https://www.cotter.app/api/v0/oauth/token/:provider_name/:cotter_user_id`

Delete an access token from a provider for the user.

#### Path Parameters

| Name             | Type   | Description               |
| ---------------- | ------ | ------------------------- |
| cotter\_user\_id | string | The user's Cotter User ID |
| provider\_name   | string | One of: `GITHUB`          |

#### Headers

| Name             | Type   | Description         |
| ---------------- | ------ | ------------------- |
| API\_KEY\_ID     | string | Your API Key ID     |
| API\_SECRET\_KEY | string | Your API Secret Key |

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

```
{
  "ID": "00000000-0000-0000-0000-000000000000",
  "created_at": "0001-01-01T00:00:00Z",
  "updated_at": "2020-09-04T05:09:16.136898006Z",
  "deleted_at": "2020-09-04T05:09:16.13689443Z",
  "company_id": "00000000-0000-0000-0000-000000000000",
  "user_id": "00000000-0000-0000-0000-000000000000",
  "provider_user_id": "",
  "provider_username": "",
  "identity_provider": "",
  "tokens": null
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cotter.app/sdk-reference/web/sign-in-with-social-login-provider/getting-access-tokens-from-social-login-providers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
