# OAuth Token Info

> **GET** `https://api.us.nylas.com/v3/connect/tokeninfo`

Source: https://developer.nylas.com/docs/reference/api/authentication-apis/info_oauth2_token/

Get info about a specific token based on the identifier you include. Use _either_ the ID Token or Access Token.</br></br>**Note**: Because Nylas uses the schema outlined in [RFC 9068](https://datatracker.ietf.org/doc/html/rfc9068#name-requesting-a-jwt-access-tok) to ensure that it is compatible with all OAuth libraries in all languages, the format for this endpoint is different from the other OAuth endpoints.


**Authentication:** ACCESS_TOKEN, NYLAS_API_KEY

## Parameters

### Query parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id_token` | string | No | ID token |
| `access_token` | string | No | Access token |

## Responses

### 200 - Returns Token info

- `request_id` (string) - ID of the request
- `data` (object)
  - `iss` (string) - Token's issuer
  - `aud` (string) - Token's audience
  - `sub` (string) - Token's subject
  - `email` (string) - Email of grant's user token belongs to
  - `iat` (integer) - Token issued at
  - `exp` (integer) - Token expires at

### 400 - Bad request

- `error` (string) - Error type constant.
- `error_description` (string) - Human readable error description.
- `error_uri` (string) - A url to the related documentation and troubleshooting regarding this error.
- `error_code` (string) - Error code used for referencing the docs, logs and data stream.

## Code samples

### cURL

```bash
curl --request GET \
  --url 'https://api.us.nylas.com/v3/connect/tokeninfo?id_token=<ACCESS_TOKEN_ID>&access_token=<NYLAS_ACCESS_TOKEN>' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
```

### Node.js SDK

```javascript
import Nylas from "nylas";

const nylas = new Nylas({
  apiKey: "<NYLAS_API_KEY>",
  apiUri: "<NYLAS_API_URI>",
});

const accessToken = "<ACCESS_TOKEN>";

try {
  const tokenInfo = await nylas.auth.accessTokenInfo(accessToken);
  console.log("Token info:", tokenInfo);
} catch (error) {
  console.error("Error fetching token info:", error);
}

```

### Python SDK

```python
import sys
from nylas import Client

nylas = Client(
    "<NYLAS_API_KEY>",
    "<NYLAS_API_URI>"
)

request = nylas.auth.id_token_info(
  "<ACCESS_TOKEN_ID>",
)

print(request)
```

### Ruby SDK

```ruby
require 'nylas'	

nylas = Nylas::Client.new(
	  api_key: "<NYLAS_API_KEY>"
)

query_params = {
    id_token: "<ACCESS_TOKEN_ID>"
}

token_info = nylas.auth.access_token_info(query_params: query_params)

puts token_info

```

### Java SDK

```java
import com.nylas.NylasClient;
import com.nylas.models.*;

public class GetTokenInfo {
  public static void main(String[] args) throws NylasSdkTimeoutError, NylasApiError {
    NylasClient nylas = new NylasClient.Builder("<NYLAS_API_KEY>").build();
    Response<TokenInfoResponse> token = nylas.auth().idTokenInfo("<ACCESS_TOKEN_ID>");
    
    System.out.println(token);
  }
}

```

### Kotlin SDK

```kotlin
import com.nylas.NylasClient

fun main(args: Array<String>) {
  val nylas: NylasClient = NylasClient(
      apiKey = "<NYLAS_API_KEY>"
  )

  val token = nylas.auth().idTokenInfo("<ACCESS_TOKEN_ID>")
  
  print(token)
}

```
