stack/docs-mintlify/api/admin/oauth/authorize.mdx
Madison 13fccd32b6
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
DB migration compat / Check if migrations changed (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Build and Run / docker (push) Has been cancelled
Runs E2E API Tests (Local Emulator) / E2E Tests (Local Emulator, Node ${{ matrix.node-version }}) (22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (mock, 22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (prod, 22.x) (push) Has been cancelled
Runs E2E API Tests with custom port prefix / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Dev Environment Test With Custom Base Port / restart-dev-and-test-with-custom-base-port (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests with custom base port / setup-tests-with-custom-base-port (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
DB migration compat / Back-compat — Current branch migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migration compat / Forward-compat — Current branch code with ${{ needs.check-migrations-changed.outputs.base_branch }} branch migrations (push) Has been cancelled
DB migration compat / No migration changes (skipped) (push) Has been cancelled
Add docs-mintlify to root
2026-04-01 14:58:41 -05:00

111 lines
3.2 KiB
Plaintext

---
title: "OAuth Authorize Endpoint"
description: "Initiate the OAuth authorization flow to authenticate a user or link an existing user with an OAuth provider."
api: "GET /api/v1/auth/oauth/authorize/{provider_id}"
---
## Request
### Path Parameters
<ParamField path="provider_id" type="string" required>
The OAuth provider identifier.
</ParamField>
### Query Parameters
<ParamField query="type" type="string" default="authenticate">
The type of OAuth flow. Use `authenticate` to sign in a user, or `link` to link an existing user with a provider.
</ParamField>
<ParamField query="token" type="string" default="">
Token for authentication context.
</ParamField>
<ParamField query="provider_scope" type="string">
Additional OAuth scopes to request from the provider.
</ParamField>
<ParamField query="error_redirect_uri" type="string">
The URI to redirect to in case of an error.
</ParamField>
<ParamField query="after_callback_redirect_url" type="string">
The URL to redirect to after the OAuth callback is complete.
</ParamField>
<ParamField query="client_id" type="string" required>
The OAuth client ID.
</ParamField>
<ParamField query="client_secret" type="string" required>
The OAuth client secret.
</ParamField>
<ParamField query="redirect_uri" type="string" required>
The URI to redirect to after authorization.
</ParamField>
<ParamField query="scope" type="string" required>
The OAuth scopes to request.
</ParamField>
<ParamField query="state" type="string" required>
An opaque value used to maintain state between the request and callback.
</ParamField>
<ParamField query="grant_type" type="string" required>
The grant type for the OAuth flow.
</ParamField>
<ParamField query="code_challenge" type="string" required>
The PKCE code challenge.
</ParamField>
<ParamField query="code_challenge_method" type="string" required>
The PKCE code challenge method (e.g., `S256`).
</ParamField>
<ParamField query="response_type" type="string" required>
The response type for the OAuth flow (e.g., `code`).
</ParamField>
### Headers
<ParamField header="X-Stack-Project-Id" type="string">
The unique identifier of the project.
</ParamField>
<ParamField header="X-Stack-Publishable-Client-Key" type="string">
The publishable client key.
</ParamField>
## Response (302)
Redirects the user to the OAuth provider's authorization page.
<CodeGroup>
```bash cURL
curl -X GET "https://api.stack-auth.com/api/v1/auth/oauth/authorize/google?client_id=<client-id>&client_secret=<client-secret>&redirect_uri=https://example.com/callback&scope=openid+email&state=<state>&grant_type=authorization_code&code_challenge=<challenge>&code_challenge_method=S256&response_type=code" \
-H "X-Stack-Project-Id: <project-id>" \
-H "X-Stack-Publishable-Client-Key: <client-key>" \
-L
```
```javascript JavaScript
const params = new URLSearchParams({
client_id: "<client-id>",
client_secret: "<client-secret>",
redirect_uri: "https://example.com/callback",
scope: "openid email",
state: "<state>",
grant_type: "authorization_code",
code_challenge: "<challenge>",
code_challenge_method: "S256",
response_type: "code"
});
window.location.href = `https://api.stack-auth.com/api/v1/auth/oauth/authorize/google?${params}`;
```
</CodeGroup>