# Getting the Tokens

Getting Cotter's OAuth Tokens is very easy using our current authentication methods. **You should automatically receive the `oauth_token` whenever a user is succesfully authenticated**, either using magic link, OTP, trusted device, or WebAuthn.

You will get an `oauth_token` object in the JSON response with all the tokens:

```javascript
{
  ...
  "oauth_token": {
    "access_token": "eyJhbGciOiJFUzI1sInR5cC...",
    "auth_method": "TRUSTED_DEVICE", // authentication method used
    "expires_in": 3600,              // expiry in seconds
    "id_token": "eyJhbGciOiJFUz...",
    "refresh_token": "60:79hbLxl3aTjWWgCcIRnn...",
    "token_type": "Bearer"
  }
}
```

## Getting Tokens using the SDK

There are 3 places in the existing SDK where you can receive access tokens:

{% content-ref url="/pages/-M4HjKz1atn3w5W-syVN" %}
[During Email/Phone Verification](/getting-access-token/older-api/getting-the-tokens/during-authentication/during-email-phone-verification.md)
{% endcontent-ref %}

{% content-ref url="/pages/-M4I2UtJdxzuT\_JMHsKv" %}
[During Authentication](/getting-access-token/older-api/getting-the-tokens/during-authentication.md)
{% endcontent-ref %}

{% content-ref url="/pages/-M4IuiqhSaH4ha2Ye8zu" %}
[During enrolling Trusted Devices](/getting-access-token/older-api/getting-the-tokens/during-enrolling-trusted-devices.md)
{% endcontent-ref %}

## Getting Tokens using HTTP Request

You can also call Cotter's API to get the tokens.

{% content-ref url="/pages/-M4JGrVHEcLJ12a9rzYj" %}
[Using the Refresh Token](/getting-access-token/getting-the-tokens/using-http-requests.md)
{% endcontent-ref %}


---

# 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/getting-access-token/getting-the-tokens.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.
