Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .optimize-cache.json
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,7 @@
"images/blog/why-you-need-to-try-the-new-bun-runtime/bun-buildtime.png": "69b92a76d4e7935d666da1b010e6606a8b73c009de23e00a891c551fb1d042dd",
"images/blog/why-you-need-to-try-the-new-bun-runtime/cover.png": "96d6da52011044ed190620d57510a98964bec3f3339712960acead8f2208529a",
"images/blog/why-you-need-to-try-the-new-bun-runtime/ts-buildtime.png": "f1e53206a80937c86b33f615ba6936a8c10266dc01ba221da4a7c2735e806ae9",
"images/blog/x-oauth2-appwrite/cover.png": "1e6bfcc38f758e57a684a3b092bd8500e45353e7dc164af20753882ecbf8373e",
"images/brand/new-brand-grid-desktop.png": "3469b9692f5f8be1a635974c14a3e55c0f311559e499ffe83a145234db93da90",
"images/brand/new-brand-grid-mobile.png": "129543e6f56036bbfd3f0e8e12534b179b3202885f687ab71429f7b6c7e95fd2",
"images/brand/t-shirts.png": "ae53c30bc47e43ac23ffdcd54a90e5bdf7170e04eeb2e7c3f758e771dfd29e1e",
Expand Down Expand Up @@ -1617,6 +1618,7 @@
"images/integrations/avatars/vonage.png": "b9d22975cae0fc7234c761b8ea5d92260db73cc027e756ede9aa47cc2efde44e",
"images/integrations/avatars/vuepress.png": "7893861c4fdb3bc037381962aa4ada05156d8df276d5300925c8fd8d66063e23",
"images/integrations/avatars/windsurf.png": "41d48db8811ebe2c5bffb965615ede43bee55ef73cb751db4ffc7499e576033c",
"images/integrations/avatars/x.png": "cd24d39505021b078939ca05fba4ddb5d0e67afedc2a02c29837b097abb1904e",
"images/integrations/deployments-github/cover.png": "c425b990a458a660eec087677bf4ce81cc9a188115654ef56bed4791f6c03d03",
"images/integrations/deployments-github/create.png": "64477b19f98d50a3648fc9b5e2587a45a694297480277e2806dd30c60b7f7e67",
"images/integrations/deployments-github/installed.png": "14cb46d5dcca35a8df915c571505a6198adba52afb24968a75a248fcfdb416f4",
Expand Down Expand Up @@ -1689,6 +1691,10 @@
"images/integrations/oauth-notion/new-integration.png": "57a8cc8b3fc5f5ae221ac3a985af020aaedb3b33056a554874103d0969128b32",
"images/integrations/oauth-notion/provider.png": "cbe618d08defc00beb58350b8f4c7e2d0d3bbe64f4ecb000e74f26c2c8cc7f69",
"images/integrations/oauth-notion/redirect-uri.png": "2d02a9c29a75784055ed10e385fa8262935eb218e7a4c1f14d908699dba10570",
"images/integrations/oauth-x/cover.png": "fb6577a5bb5f067b6a5f2bd20d6f9cdcb5c02c5fd7d2e73f9fcc7402ddcaa121",
"images/integrations/oauth-x/new-app.png": "17542433411284fba2e859357094fda7da33c4790b38a7608f4e67f3cfab5151",
"images/integrations/oauth-x/oauth2.png": "c6ba6f6f84d042c1acac2470f794f53a855b775373feebdee852fdd0683ac99f",
"images/integrations/oauth-x/provider.png": "d53f59c3b3caf263bc77ca3c5490f7b501d5e4befd7c904341f446bd463685e8",
"images/integrations/phone-auth-twilio/cover.png": "e46ab3a1a8b458b69e919219e35de4a15b2bbd0ea9c0079c0c99e005acf3a295",
"images/integrations/phone-auth-twilio/twilio-console.png": "bd3081b13711088c437ed10553709ca4af54f80c81571b30b6cc9a4a1fab1799",
"images/integrations/phone-auth-twilio/user.png": "a526a9621c30de2ba4b6b08508d15bcf588b7de5cafadaf3ea7a8198485cf53e",
Expand Down
153 changes: 153 additions & 0 deletions src/routes/blog/post/x-oauth2-appwrite/+page.markdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
---
layout: post
title: Announcing X OAuth support in Appwrite Auth
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about Announcing X OAuth 2.0 support in Appwrite Auth ? 🤔

description: Appwrite now supports X (formerly Twitter) OAuth2 login. Learn how to add it to your app in minutes.
date: 2026-04-09
cover: /images/blog/x-oauth2-appwrite/cover.png
timeToRead: 5
author: aditya-oberai
category: announcement, tutorial
featured: false
---

We're excited to announce that Appwrite Auth now includes an X OAuth adapter. You can now let users sign in with their X account using Appwrite's built-in OAuth2 support, with no custom backend code required.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call it OAuth2 adapter to be more consistent everywhere


X is one of the most widely used social platforms, with hundreds of millions of active users. Adding "Sign in with X" gives your users a fast, familiar way to get started without creating a new account, and gives you a verified identity to work with from day one.

In this guide, we'll walk through what this means for your app, why it matters, and how to set it up.

# Why X OAuth is useful for developers and users

For users, social login removes the friction of registration. There's no new password to create or forget, no verification email to wait for. They click one button, approve access, and they're in.

For developers, social login with Appwrite means you don't have to implement or maintain any OAuth infrastructure yourself. Appwrite handles the redirect, the token exchange, the session creation, and the refresh flow. You call one SDK method. The rest happens server-side.

X in particular is valuable for apps that are social or content-focused. If your users are already on X, letting them authenticate with it creates a natural connection between their X identity and your product. You can also use the access token Appwrite stores to call the X API on their behalf, enabling things like reading their profile, fetching their posts, or building X-connected features.

# How OAuth2 works in Appwrite

When a user signs in with X, Appwrite manages the entire OAuth2 flow on your behalf:

1. Your app calls an Appwrite SDK method, which returns an authorization URL.
2. The user is redirected to X's consent screen.
3. After granting access, X redirects back to Appwrite with an authorization code.
4. Appwrite exchanges the code for an access token and refresh token with X.
5. Appwrite redirects the user to your success URL with a `userId` and `secret`.
6. Your app uses these to create an Appwrite session.

Appwrite's X adapter uses **OAuth 2.0 with PKCE** (Proof Key for Code Exchange), which is required by X's API v2 and adds an extra layer of security by preventing authorization code interception attacks.

# Creating an X Developer app

To connect Appwrite to X, you first need to register an app on the [X Developer Console](https://console.x.com).

Log in and create a new project, then create a new app inside that project (or use an existing one). Give your app a name that reflects what you're building.

![X Developer Console - New App](/images/integrations/oauth-x/new-app.png)

Once the app is created, open the app's **Settings** and scroll down to **User authentication settings**. Click **Set up** and configure the following:

- **App permissions**: Select **Read** at a minimum. If your app needs to post or access direct messages, select the appropriate permissions.
- **Type of App**: Select **Web App, Automated App or Bot**.
- **Callback URI / Redirect URL**: Temporarily add `https://temporary-endpoint.com/`. You'll replace this with the real URI from Appwrite in the next step.

![X OAuth2 user authentication settings](/images/integrations/oauth-x/oauth2.png)

After saving, X will display a **Client ID** and **Client Secret**. Save both. The Client Secret is only shown once, so copy it somewhere safe before closing the page.

# Enabling X as a provider in Appwrite

Head to your [Appwrite Console](https://cloud.appwrite.io/) and open your project. Navigate to **Auth** > **Settings**, scroll to **OAuth2 Providers**, and click on **X**.

![X OAuth2 provider in Appwrite](/images/integrations/oauth-x/provider.png)

Enable the provider and paste in your **Client ID** and **Client Secret**. Appwrite will display a **Redirect URI**. Copy it and go back to your X app's **User authentication settings** to replace the temporary callback URL with this value.

Save the changes in both the X Developer Console and Appwrite.

# Logging in from your frontend

With the provider configured, you can trigger X login using the Appwrite SDK. Here's an example using the JavaScript SDK:

```js
import { Client, Account, OAuthProvider } from 'appwrite';

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

const account = new Account(client);

const authUrl = await account.createOAuth2Token({
provider: OAuthProvider.X,
success: 'https://your-app.com/auth/callback',
failure: 'https://your-app.com/auth/login?error=oauth'
});

window.location.href = authUrl;
```

Then on your callback page, read the `userId` and `secret` from the query string and create the session manually:

```js
const params = new URLSearchParams(window.location.search);
const userId = params.get('userId');
const secret = params.get('secret');

if (userId && secret) {
await account.createSession({ userId, secret });
window.location.href = '/dashboard';
}
```

# Accessing user data

After login, you can fetch the authenticated user's profile from Appwrite:

```js
const user = await account.get();

console.log(user.name); // display name from X
console.log(user.email); // email from X (if granted)
```

If you need the X access token to call the X API directly, retrieve it from the user's identities:

```js
const { identities } = await account.listIdentities();
const xIdentity = identities.find(i => i.provider === 'x');

console.log(xIdentity.providerAccessToken); // X OAuth2 access token
```

You can use this access token to make requests to the [X API v2](https://docs.x.com) on behalf of the user.

# Refreshing the access token

X access tokens expire. When you need a fresh token, call `updateSession` to silently renew it using the stored refresh token:

```js
await account.updateSession({ sessionId: 'current' });

const { identities } = await account.listIdentities();
const xIdentity = identities.find(i => i.provider === 'x');

console.log(xIdentity.providerAccessToken); // fresh token
```

This renews the X access token without interrupting the user's Appwrite session.

# Final thoughts

Adding X login to your app with Appwrite comes down to three things: registering an app on the X Developer Console, configuring the provider in the Appwrite Console, and calling one SDK method. Appwrite handles the PKCE flow, token exchange, and session management for you.

If you have questions or run into issues, the [Appwrite Discord server](https://appwrite.io/discord) is the best place to get help.

# Further reading

- [X OAuth integration guide](/integrations/oauth-x)
- [Appwrite Auth OAuth2 docs](/docs/products/auth/oauth2)
- [X Developer Console](https://console.x.com)
- [X API OAuth2 documentation](https://docs.x.com/fundamentals/authentication/oauth-2-0/overview)
- [Understanding OAuth and OpenID Connect](/blog/post/oauth-openid)
- [Appwrite Auth API reference](/docs/references/cloud/client-web/account)
7 changes: 0 additions & 7 deletions src/routes/integrations/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,6 @@
{/if}
{/each}
</ul>
<Button
variant="text"
href={`#${category.toLowerCase()}`}
class="l-float-button"
>
<span>Show more</span>
</Button>
</div>
</section>
{/if}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/integrations/flutterflow-auth-kit/+page.markdoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: integration
title: Auth Kit for FlutterFlow
description: Integrate Appwrite Auth into your FlutterFlow apps without writing complex code
date: 2024-03-01
featured: true
featured: false
isPartner: true
isNew: true
cover: /images/integrations/flutterflow-auth-kit/cover.png
Expand Down
67 changes: 67 additions & 0 deletions src/routes/integrations/oauth-x/+page.markdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
layout: integration
title: OAuth with X
description: Authenticate users with an existing X account
date: 2026-04-09
featured: true
isPartner: true
isNew: true
cover: /images/integrations/oauth-x/cover.png
category: auth
product:
avatar: '/images/integrations/avatars/x.png'
vendor: X
description: 'X is a social media platform where users can post short messages, follow others, and engage in real-time conversations on topics ranging from news and politics to entertainment and technology.'
platform:
- 'Cloud'
images:
- /images/integrations/oauth-x/cover.png
- /images/integrations/oauth-x/new-app.png
- /images/integrations/oauth-x/oauth2.png
- /images/integrations/oauth-x/provider.png
---

X, formerly known as Twitter, is a social media platform where users can post short messages, follow others, and engage in real-time conversations on topics ranging from news and politics to entertainment and technology. With hundreds of millions of active users worldwide, X is one of the most widely used social platforms and provides OAuth 2.0 support, allowing developers to authenticate users through their existing X accounts.

# How does the integration work?

You can use the X OAuth adapter in Appwrite Auth for user authentication and management. This can be convenient for users because they can start using your app without creating a new account. It can also be more secure, because the user has one less password that could become vulnerable.

# How to implement

To implement the X OAuth adapter in Appwrite Auth, there are several steps you must complete:

## Step 1: Create an X Developer app

First, head to the [X Developer Console](https://console.x.com/) and create a new project. In the **Apps** section, create a new app inside the project (or use an existing one). Give your app a name that reflects what you're building.

In your app's settings, scroll down to **User authentication settings** and click **Set up**. Configure the following:

- **App permissions**: Select **Read** at minimum.
- **Type of App**: Select **Web App, Automated App or Bot**.
- **Callback URI / Redirect URL**: Temporarily add `https://temporary-endpoint.com/`. This will be replaced with the actual URI once the OAuth2 adapter is configured on Appwrite.

![OAuth 2.0 settings](/images/integrations/oauth-x/oauth2.png)

After saving, X will display a **Client ID** and **Client Secret**. Save both values for later use.

## Step 2: Add X OAuth adapter to your Appwrite project

For this step, you must [create an account on Appwrite Cloud](https://cloud.appwrite.io/register) if you haven't already. In your Appwrite project, head over to the **Auth** page, open the **Settings** tab, and click on **X** under the **OAuth2 Providers** section.

![X provider](/images/integrations/oauth-x/provider.png)

Add the **Client ID** and **Client Secret** you saved from your X app and copy the URI to replace the temporary URL in the **Callback URI / Redirect URL** field in your X app's user authentication settings.

## Step 3: Test the provider

Follow the [OAuth 2 login](/docs/products/auth/oauth2#init) flow to test your provider.

# Read more about X and Appwrite Auth

If you would like to learn more about X and Appwrite Auth, we have some resources that you should visit:

- [X Developer Console](https://console.x.com)
- [Implement OAuth login in your apps using Appwrite Auth](/docs/products/auth/oauth2)
- [Understanding OAuth and OpenID Connect](/blog/post/oauth-openid)
- [Appwrite Auth API reference](/docs/references/cloud/client-web/account)
Binary file modified static/assets/visuals/auth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/assets/visuals/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/assets/visuals/databases.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/assets/visuals/functions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/assets/visuals/messaging.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/assets/visuals/storage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/blog/x-oauth2-appwrite/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/integrations/avatars/x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/integrations/oauth-x/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/integrations/oauth-x/new-app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/integrations/oauth-x/oauth2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/integrations/oauth-x/provider.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading