stack/docs-mintlify/api/admin/oauth/create-provider.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

119 lines
3.9 KiB
Plaintext

---
title: "Create an OAuth Provider"
description: "Add a new OAuth provider for a user."
api: "POST /api/v1/oauth-providers"
---
## Request
### Headers
<ParamField header="X-Stack-Project-Id" type="string">
The unique identifier of the project.
</ParamField>
<ParamField header="X-Stack-Secret-Server-Key" type="string">
The secret server key.
</ParamField>
<ParamField header="X-Stack-Super-Secret-Admin-Key" type="string">
The super secret admin key.
</ParamField>
### Body
<ParamField body="user_id" type="string" required>
The ID of the user, or the special value `me` for the currently authenticated user.
</ParamField>
<ParamField body="provider_config_id" type="string" required>
The provider config ID for the OAuth provider.
</ParamField>
<ParamField body="email" type="string">
Email of the OAuth provider. This is used to display and identify the OAuth provider in the UI.
</ParamField>
<ParamField body="allow_sign_in" type="boolean" required>
Whether the user can use this OAuth provider to sign in. Only one OAuth provider per type can have this set to `true`.
</ParamField>
<ParamField body="allow_connected_accounts" type="boolean" required>
Whether the user can use this OAuth provider as connected account. Multiple OAuth providers per type can have this set to `true`.
</ParamField>
<ParamField body="account_id" type="string" required>
Account ID of the OAuth provider. This uniquely identifies the account on the provider side.
</ParamField>
## Response (201)
<ResponseField name="account_id" type="string" required>
Account ID of the OAuth provider. This uniquely identifies the account on the provider side.
</ResponseField>
<ResponseField name="user_id" type="string" required>
The ID of the user, or the special value `me` for the currently authenticated user.
</ResponseField>
<ResponseField name="id" type="string" required>
The unique identifier of the OAuth provider.
</ResponseField>
<ResponseField name="email" type="string">
Email of the OAuth provider. This is used to display and identify the OAuth provider in the UI.
</ResponseField>
<ResponseField name="provider_config_id" type="string" required>
Provider config ID of the OAuth provider. This uniquely identifies the provider config on config.json file.
</ResponseField>
<ResponseField name="type" type="string" required>
OAuth provider type, one of `google`, `github`, `microsoft`, `spotify`, `facebook`, `discord`, `gitlab`, `bitbucket`, `linkedin`, `apple`, `x`, `twitch`.
</ResponseField>
<ResponseField name="allow_sign_in" type="boolean" required>
Whether the user can use this OAuth provider to sign in. Only one OAuth provider per type can have this set to `true`.
</ResponseField>
<ResponseField name="allow_connected_accounts" type="boolean" required>
Whether the user can use this OAuth provider as connected account. Multiple OAuth providers per type can have this set to `true`.
</ResponseField>
<CodeGroup>
```bash cURL
curl -X POST "https://api.stack-auth.com/api/v1/oauth-providers" \
-H "Content-Type: application/json" \
-H "X-Stack-Project-Id: <project-id>" \
-H "X-Stack-Super-Secret-Admin-Key: <admin-key>" \
-d '{
"user_id": "3241a285-8329-4d69-8f3d-316e08cf140c",
"provider_config_id": "google",
"email": "test@gmail.com",
"allow_sign_in": true,
"allow_connected_accounts": true,
"account_id": "google-account-id-12345"
}'
```
```javascript JavaScript
const response = await fetch("https://api.stack-auth.com/api/v1/oauth-providers", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Stack-Project-Id": "<project-id>",
"X-Stack-Super-Secret-Admin-Key": "<admin-key>"
},
body: JSON.stringify({
user_id: "3241a285-8329-4d69-8f3d-316e08cf140c",
provider_config_id: "google",
email: "test@gmail.com",
allow_sign_in: true,
allow_connected_accounts: true,
account_id: "google-account-id-12345"
})
});
const data = await response.json();
```
</CodeGroup>