---
title: "OAuth2 callback for data source authorization"
method: GET
path: "/v1/data_sources/oauth2/callback"
tags: ["data_sources"]
---

# OAuth2 callback for data source authorization

`GET /v1/data_sources/oauth2/callback`

OAuth2 callback endpoint for completing data source authorization.

This endpoint is called by OAuth2 providers after user authorization.
It exchanges the authorization code for access tokens and stores them
securely for the data source.

Args:
    state: OAuth2 state parameter used for CSRF protection
    code: Authorization code from the OAuth2 provider
    error: OAuth2 error code if authorization was denied or failed
    error_description: Human-readable description of the error

Returns:
    Redirect to the data source details page on success

Raises:
    OAuth2TokenExchangeError: When OAuth2 provider returns an error
    InvalidStateError: When state parameter is invalid or expired

## Query parameters

- `state` string, required — OAuth2 state parameter for CSRF protection
- `code` string, required — Authorization code from OAuth2 provider
- `error` string, nullable — OAuth2 error code if authorization failed
- `error_description` string, nullable — Human-readable error description

## Other responses

- `307` — Successful authorization, redirect to data source
- `400` — OAuth2 error or invalid parameters
- `404` — Invalid or expired state parameter
- `422` — Validation Error

---

[API](https://skmtc.net/mixedbread/apis/mxbai-omni.md) · [All operations](https://skmtc.net/mixedbread/apis/mxbai-omni/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/mixedbread/mxbai-omni/versions/2eece97b5ae5/schema)
