---
title: "Sign in with an OAuth token"
description: "Exchange a provider token for Truememory tokens.\n\nFor the client-side flow: your frontend completes sign-in with the\nprovider SDK and posts the resulting token here, which is verified with\nGoogle Identity Platform before Truememory tokens are issued. Send\neither ``id_token`` or ``access_token``."
---

> Documentation Index
> Fetch the complete documentation index at: https://truememory-docs.mvstg.com/llms.txt
> Use this file to discover all available pages before exploring further.

Path: Auth API › OAuth

`POST /auth/oauth/token`

Exchange a provider token for Truememory tokens.

For the client-side flow: your frontend completes sign-in with the
provider SDK and posts the resulting token here, which is verified with
Google Identity Platform before Truememory tokens are issued. Send
either ``id_token`` or ``access_token``.

## Request body

_Required._

- `provider` (`oauth_token_auth_oauth_token_post.provider`; string, required) — OAuth provider name.
  - one of `"google"`, `"apple"`
- `id_token` (`oauth_token_auth_oauth_token_post.id_token`; any of, optional) — ID token from the OAuth provider (preferred over access_token).
  - any of: `string`, `null`
- `access_token` (`oauth_token_auth_oauth_token_post.access_token`; any of, optional) — Access token from the OAuth provider (used when id_token unavailable).
  - any of: `string`, `null`
- `nonce` (`oauth_token_auth_oauth_token_post.nonce`; any of, optional) — Raw nonce for Apple Sign-In tokens generated with a hashed nonce (e.g. expo-apple-authentication).
  - any of: `string`, `null`
- `tenant_id` (`oauth_token_auth_oauth_token_post.tenant_id`; any of, optional) — Google Identity Platform tenant ID for tenant-scoped sign-in.
  - any of: `string`, `null`
- `metadata` (`oauth_token_auth_oauth_token_post.metadata`; any of, optional) — Initial metadata to store on first-time OAuth signup. Max 50 keys, 16 KB.
  - any of: `object`, `null`

## Example request

```json
{
  "provider": "google",
  "id_token": "string",
  "access_token": "string",
  "nonce": "string",
  "tenant_id": "vibrantly-1234",
  "metadata": {}
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://truememory-auth.mvstg.com/auth/oauth/token \
  --header 'Content-Type: application/json' \
  --data '
{
  "provider": "google",
  "id_token": "string",
  "access_token": "string",
  "nonce": "string",
  "tenant_id": "vibrantly-1234",
  "metadata": {}
}
'
```

### TypeScript

```typescript
const url = 'https://truememory-auth.mvstg.com/auth/oauth/token';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    provider: 'google',
    id_token: 'string',
    access_token: 'string',
    nonce: 'string',
    tenant_id: 'vibrantly-1234',
    metadata: {}
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://truememory-auth.mvstg.com/auth/oauth/token"

payload = {
    "provider": "google",
    "id_token": "string",
    "access_token": "string",
    "nonce": "string",
    "tenant_id": "vibrantly-1234",
    "metadata": {}
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

Successful Response

#### Example

```json
{
  "id_token": "string",
  "refresh_token": "string",
  "expires_in": "string",
  "user": {
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "tenant_id": "34f5c98e-f430-457b-a812-92637d0c6fd0",
    "gip_uid": "string",
    "email": "string",
    "email_verified": false,
    "username": "string",
    "display_name": "string",
    "photo_url": "string",
    "phone_number": "string",
    "disabled": false,
    "role": "user",
    "metadata": {},
    "raw_app_meta_data": {},
    "custom_claims": {},
    "last_sign_in_at": "2019-08-24T14:15:22Z",
    "created_at": "2019-08-24T14:15:22Z",
    "updated_at": "2019-08-24T14:15:22Z",
    "deleted_at": "2019-08-24T14:15:22Z",
    "deletion_completed_at": "2019-08-24T14:15:22Z"
  }
}
```

- `id_token` (`oauth_token_auth_oauth_token_post.response.200.id_token`; string, required)
- `refresh_token` (`oauth_token_auth_oauth_token_post.response.200.refresh_token`; string, required)
- `expires_in` (`oauth_token_auth_oauth_token_post.response.200.expires_in`; string, required)
- `user` (`oauth_token_auth_oauth_token_post.response.200.user`; any of, optional)
  - any of: `AuthUser`, `null`

### 422

Validation Error

#### Example

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}
```

- `detail` (`oauth_token_auth_oauth_token_post.response.422.detail`; array<object>, optional)
  - `loc` (`oauth_token_auth_oauth_token_post.response.422.detail.loc`; array<any of>, required)
    - any of: `string`, `integer`
  - `msg` (`oauth_token_auth_oauth_token_post.response.422.detail.msg`; string, required)
  - `type` (`oauth_token_auth_oauth_token_post.response.422.detail.type`; string, required)
  - `input` (`oauth_token_auth_oauth_token_post.response.422.detail.input`; unknown, optional)
  - `ctx` (`oauth_token_auth_oauth_token_post.response.422.detail.ctx`; object, optional)


Source: https://truememory-docs.mvstg.com/auth/oauth/token/index.md
