Skip to content

OAuth providers

OAuth2 providers let your users sign in with accounts they already have, such as GitHub, Google, or Apple. Each provider stores a client ID and client secret at the project level, and can be enabled or disabled independently.

You can configure providers from the Appwrite Console or programmatically with a Server SDK. Each provider has its own update method (updateOAuth2GitHub, updateOAuth2Google, and so on), the read methods listOAuth2Providers and getOAuth2Provider cover all of them.

Configure from the Console

OAuth2 providers in the Appwrite Console

OAuth2 providers in the Appwrite Console

To configure a provider from the Console:

  1. Open your project in the Appwrite Console.
  2. Navigate to Auth in the sidebar, then open the Settings tab.
  3. Find the provider in the OAuth2 Providers list and click it.
  4. Enter the credentials from the provider (the field names vary per provider, see Available providers).
  5. Toggle the provider on and click Update.

Configure a provider

Each provider has a dedicated update method named updateOAuth2<Provider>. The example below configures GitHub. Swap the method name and credential fields to configure a different provider, the field names per provider are listed in Available providers.

Required scopes

The API key used for these calls needs oauth2.write to configure providers, and oauth2.read to list or fetch them.

Enabling validates credentials

Setting enabled to true triggers end-to-end validation of the credentials against the provider, and the request throws if they are invalid. To store credentials without activating the provider yet, send them with enabled set to false.

import { Client, Project } from 'node-appwrite';

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>')
    .setKey('<YOUR_API_KEY>');

const project = new Project(client);

const result = await project.updateOAuth2GitHub({
    clientId: '<CLIENT_ID>',
    clientSecret: '<CLIENT_SECRET>',
    enabled: true
});

Providers with extra fields

Some providers take more than a client ID and secret. Google, for example, accepts an additional prompt parameter that controls the consent screen behavior:

import { Client, Project, ProjectOAuth2GooglePrompt } from 'node-appwrite';

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>')
    .setKey('<YOUR_API_KEY>');

const project = new Project(client);

const result = await project.updateOAuth2Google({
    clientId: '<CLIENT_ID>',
    clientSecret: '<CLIENT_SECRET>',
    prompt: [ProjectOAuth2GooglePrompt.SelectAccount],
    enabled: true
});

Available providers

Every provider has its own updateOAuth2<Provider> method. The credential field names differ per provider, use the columns below to map the provider's credentials to the method's parameters.

ProviderSDK methodApp ID fieldApp secret fieldOther fields
Amazon
updateOAuth2Amazon
clientId
clientSecret
Apple
updateOAuth2Apple
serviceId
keyId
teamId
Auth0
updateOAuth2Auth0
clientId
clientSecret
endpoint
Authentik
updateOAuth2Authentik
clientId
clientSecret
endpoint
Autodesk
updateOAuth2Autodesk
clientId
clientSecret
Bitbucket
updateOAuth2Bitbucket
key
secret
Bitly
updateOAuth2Bitly
clientId
clientSecret
Box
updateOAuth2Box
clientId
clientSecret
Dailymotion
updateOAuth2Dailymotion
apiKey
apiSecret
Discord
updateOAuth2Discord
clientId
clientSecret
Disqus
updateOAuth2Disqus
publicKey
secretKey
Dropbox
updateOAuth2Dropbox
appKey
appSecret
Etsy
updateOAuth2Etsy
keyString
sharedSecret
Facebook
updateOAuth2Facebook
appId
appSecret
Figma
updateOAuth2Figma
clientId
clientSecret
FusionAuth
updateOAuth2FusionAuth
clientId
clientSecret
endpoint
GitHub
updateOAuth2GitHub
clientId
clientSecret
GitLab
updateOAuth2Gitlab
applicationId
secret
endpoint
Google
updateOAuth2Google
clientId
clientSecret
prompt
Keycloak
updateOAuth2Keycloak
clientId
clientSecret
endpoint, realmName
Kick
updateOAuth2Kick
clientId
clientSecret
LinkedIn
updateOAuth2Linkedin
clientId
primaryClientSecret
Microsoft
updateOAuth2Microsoft
applicationId
applicationSecret
tenant
Notion
updateOAuth2Notion
oauthClientId
oauthClientSecret
OIDC
updateOAuth2Oidc
clientId
clientSecret
wellKnownURL, authorizationURL, tokenURL, userInfoURL
Okta
updateOAuth2Okta
clientId
clientSecret
domain, authorizationServerId
PayPal
updateOAuth2Paypal
clientId
secretKey
PayPal Sandbox
updateOAuth2PaypalSandbox
clientId
secretKey
Podio
updateOAuth2Podio
clientId
clientSecret
Salesforce
updateOAuth2Salesforce
customerKey
customerSecret
Slack
updateOAuth2Slack
clientId
clientSecret
Spotify
updateOAuth2Spotify
clientId
clientSecret
Stripe
updateOAuth2Stripe
clientId
apiSecretKey
Tradeshift
updateOAuth2Tradeshift
enabled only
Tradeshift Sandbox
updateOAuth2TradeshiftSandbox
enabled only
Twitch
updateOAuth2Twitch
clientId
clientSecret
WordPress
updateOAuth2WordPress
clientId
clientSecret
X
updateOAuth2X
customerKey
secretKey
Yahoo
updateOAuth2Yahoo
clientId
clientSecret
Yandex
updateOAuth2Yandex
clientId
clientSecret
Zoho
updateOAuth2Zoho
clientId
clientSecret
Zoom
updateOAuth2Zoom
clientId
clientSecret
Apple is in beta

The Apple provider is currently in beta.

List providers

List every OAuth2 provider and its current configuration state.

import { Client, Project } from 'node-appwrite';

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>')
    .setKey('<YOUR_API_KEY>');

const project = new Project(client);

const result = await project.listOAuth2Providers({
    queries: [],
    total: false
});

Get a provider

Fetch a single provider's configuration by its provider ID.

import { Client, Project, ProjectOAuthProviderId } from 'node-appwrite';

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>')
    .setKey('<YOUR_API_KEY>');

const project = new Project(client);

const result = await project.getOAuth2Provider({
    providerId: ProjectOAuthProviderId.Github
});

Benefits

  • Repeatable provisioning. Script the full set of OAuth2 providers a project needs and recreate it on demand, without clicking through the Console.
  • Environment parity. Keep dev, staging, and production projects in sync by running the same configuration script against each one.
  • Server-only secrets. Client secrets are write-only over the API and never returned in responses, so configuration scripts can run in CI without exposing them.