Skip to content

Commit fa61298

Browse files
authored
Merge pull request #2873 from appwrite/add-x-integration-guide
Announce X OAuth integration
2 parents c174258 + b4c8e97 commit fa61298

File tree

17 files changed

+227
-8
lines changed

17 files changed

+227
-8
lines changed

β€Ž.optimize-cache.jsonβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@
11081108
"images/blog/why-you-need-to-try-the-new-bun-runtime/bun-buildtime.png": "69b92a76d4e7935d666da1b010e6606a8b73c009de23e00a891c551fb1d042dd",
11091109
"images/blog/why-you-need-to-try-the-new-bun-runtime/cover.png": "96d6da52011044ed190620d57510a98964bec3f3339712960acead8f2208529a",
11101110
"images/blog/why-you-need-to-try-the-new-bun-runtime/ts-buildtime.png": "f1e53206a80937c86b33f615ba6936a8c10266dc01ba221da4a7c2735e806ae9",
1111+
"images/blog/x-oauth2-appwrite/cover.png": "1e6bfcc38f758e57a684a3b092bd8500e45353e7dc164af20753882ecbf8373e",
11111112
"images/brand/new-brand-grid-desktop.png": "3469b9692f5f8be1a635974c14a3e55c0f311559e499ffe83a145234db93da90",
11121113
"images/brand/new-brand-grid-mobile.png": "129543e6f56036bbfd3f0e8e12534b179b3202885f687ab71429f7b6c7e95fd2",
11131114
"images/brand/t-shirts.png": "ae53c30bc47e43ac23ffdcd54a90e5bdf7170e04eeb2e7c3f758e771dfd29e1e",
@@ -1618,6 +1619,7 @@
16181619
"images/integrations/avatars/vonage.png": "b9d22975cae0fc7234c761b8ea5d92260db73cc027e756ede9aa47cc2efde44e",
16191620
"images/integrations/avatars/vuepress.png": "7893861c4fdb3bc037381962aa4ada05156d8df276d5300925c8fd8d66063e23",
16201621
"images/integrations/avatars/windsurf.png": "41d48db8811ebe2c5bffb965615ede43bee55ef73cb751db4ffc7499e576033c",
1622+
"images/integrations/avatars/x.png": "cd24d39505021b078939ca05fba4ddb5d0e67afedc2a02c29837b097abb1904e",
16211623
"images/integrations/deployments-github/cover.png": "c425b990a458a660eec087677bf4ce81cc9a188115654ef56bed4791f6c03d03",
16221624
"images/integrations/deployments-github/create.png": "64477b19f98d50a3648fc9b5e2587a45a694297480277e2806dd30c60b7f7e67",
16231625
"images/integrations/deployments-github/installed.png": "14cb46d5dcca35a8df915c571505a6198adba52afb24968a75a248fcfdb416f4",
@@ -1690,6 +1692,10 @@
16901692
"images/integrations/oauth-notion/new-integration.png": "57a8cc8b3fc5f5ae221ac3a985af020aaedb3b33056a554874103d0969128b32",
16911693
"images/integrations/oauth-notion/provider.png": "cbe618d08defc00beb58350b8f4c7e2d0d3bbe64f4ecb000e74f26c2c8cc7f69",
16921694
"images/integrations/oauth-notion/redirect-uri.png": "2d02a9c29a75784055ed10e385fa8262935eb218e7a4c1f14d908699dba10570",
1695+
"images/integrations/oauth-x/cover.png": "fb6577a5bb5f067b6a5f2bd20d6f9cdcb5c02c5fd7d2e73f9fcc7402ddcaa121",
1696+
"images/integrations/oauth-x/new-app.png": "17542433411284fba2e859357094fda7da33c4790b38a7608f4e67f3cfab5151",
1697+
"images/integrations/oauth-x/oauth2.png": "c6ba6f6f84d042c1acac2470f794f53a855b775373feebdee852fdd0683ac99f",
1698+
"images/integrations/oauth-x/provider.png": "d53f59c3b3caf263bc77ca3c5490f7b501d5e4befd7c904341f446bd463685e8",
16931699
"images/integrations/phone-auth-twilio/cover.png": "e46ab3a1a8b458b69e919219e35de4a15b2bbd0ea9c0079c0c99e005acf3a295",
16941700
"images/integrations/phone-auth-twilio/twilio-console.png": "bd3081b13711088c437ed10553709ca4af54f80c81571b30b6cc9a4a1fab1799",
16951701
"images/integrations/phone-auth-twilio/user.png": "a526a9621c30de2ba4b6b08508d15bcf588b7de5cafadaf3ea7a8198485cf53e",
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
---
2+
layout: post
3+
title: Announcing X OAuth support in Appwrite Auth
4+
description: Appwrite now supports X (formerly Twitter) OAuth2 login. Learn how to add it to your app in minutes.
5+
date: 2026-04-09
6+
cover: /images/blog/x-oauth2-appwrite/cover.png
7+
timeToRead: 5
8+
author: aditya-oberai
9+
category: announcement, tutorial
10+
featured: false
11+
---
12+
13+
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.
14+
15+
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.
16+
17+
In this guide, we'll walk through what this means for your app, why it matters, and how to set it up.
18+
19+
# Why X OAuth is useful for developers and users
20+
21+
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.
22+
23+
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.
24+
25+
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.
26+
27+
# How OAuth2 works in Appwrite
28+
29+
When a user signs in with X, Appwrite manages the entire OAuth2 flow on your behalf:
30+
31+
1. Your app calls an Appwrite SDK method, which returns an authorization URL.
32+
2. The user is redirected to X's consent screen.
33+
3. After granting access, X redirects back to Appwrite with an authorization code.
34+
4. Appwrite exchanges the code for an access token and refresh token with X.
35+
5. Appwrite redirects the user to your success URL with a `userId` and `secret`.
36+
6. Your app uses these to create an Appwrite session.
37+
38+
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.
39+
40+
# Creating an X Developer app
41+
42+
To connect Appwrite to X, you first need to register an app on the [X Developer Console](https://console.x.com).
43+
44+
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.
45+
46+
![X Developer Console - New App](/images/integrations/oauth-x/new-app.png)
47+
48+
Once the app is created, open the app's **Settings** and scroll down to **User authentication settings**. Click **Set up** and configure the following:
49+
50+
- **App permissions**: Select **Read** at a minimum. If your app needs to post or access direct messages, select the appropriate permissions.
51+
- **Type of App**: Select **Web App, Automated App or Bot**.
52+
- **Callback URI / Redirect URL**: Temporarily add `https://temporary-endpoint.com/`. You'll replace this with the real URI from Appwrite in the next step.
53+
54+
![X OAuth2 user authentication settings](/images/integrations/oauth-x/oauth2.png)
55+
56+
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.
57+
58+
# Enabling X as a provider in Appwrite
59+
60+
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**.
61+
62+
![X OAuth2 provider in Appwrite](/images/integrations/oauth-x/provider.png)
63+
64+
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.
65+
66+
Save the changes in both the X Developer Console and Appwrite.
67+
68+
# Logging in from your frontend
69+
70+
With the provider configured, you can trigger X login using the Appwrite SDK. Here's an example using the JavaScript SDK:
71+
72+
```js
73+
import { Client, Account, OAuthProvider } from 'appwrite';
74+
75+
const client = new Client()
76+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
77+
.setProject('<PROJECT_ID>');
78+
79+
const account = new Account(client);
80+
81+
const authUrl = await account.createOAuth2Token({
82+
provider: OAuthProvider.X,
83+
success: 'https://your-app.com/auth/callback',
84+
failure: 'https://your-app.com/auth/login?error=oauth'
85+
});
86+
87+
window.location.href = authUrl;
88+
```
89+
90+
Then on your callback page, read the `userId` and `secret` from the query string and create the session manually:
91+
92+
```js
93+
const params = new URLSearchParams(window.location.search);
94+
const userId = params.get('userId');
95+
const secret = params.get('secret');
96+
97+
if (userId && secret) {
98+
await account.createSession({ userId, secret });
99+
window.location.href = '/dashboard';
100+
}
101+
```
102+
103+
# Accessing user data
104+
105+
After login, you can fetch the authenticated user's profile from Appwrite:
106+
107+
```js
108+
const user = await account.get();
109+
110+
console.log(user.name); // display name from X
111+
console.log(user.email); // email from X (if granted)
112+
```
113+
114+
If you need the X access token to call the X API directly, retrieve it from the user's identities:
115+
116+
```js
117+
const { identities } = await account.listIdentities();
118+
const xIdentity = identities.find(i => i.provider === 'x');
119+
120+
console.log(xIdentity.providerAccessToken); // X OAuth2 access token
121+
```
122+
123+
You can use this access token to make requests to the [X API v2](https://docs.x.com) on behalf of the user.
124+
125+
# Refreshing the access token
126+
127+
X access tokens expire. When you need a fresh token, call `updateSession` to silently renew it using the stored refresh token:
128+
129+
```js
130+
await account.updateSession({ sessionId: 'current' });
131+
132+
const { identities } = await account.listIdentities();
133+
const xIdentity = identities.find(i => i.provider === 'x');
134+
135+
console.log(xIdentity.providerAccessToken); // fresh token
136+
```
137+
138+
This renews the X access token without interrupting the user's Appwrite session.
139+
140+
# Final thoughts
141+
142+
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.
143+
144+
If you have questions or run into issues, the [Appwrite Discord server](https://appwrite.io/discord) is the best place to get help.
145+
146+
# Further reading
147+
148+
- [X OAuth integration guide](/integrations/oauth-x)
149+
- [Appwrite Auth OAuth2 docs](/docs/products/auth/oauth2)
150+
- [X Developer Console](https://console.x.com)
151+
- [X API OAuth2 documentation](https://docs.x.com/fundamentals/authentication/oauth-2-0/overview)
152+
- [Understanding OAuth and OpenID Connect](/blog/post/oauth-openid)
153+
- [Appwrite Auth API reference](/docs/references/cloud/client-web/account)

β€Žsrc/routes/integrations/+page.svelteβ€Ž

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,6 @@
389389
{/if}
390390
{/each}
391391
</ul>
392-
<Button
393-
variant="text"
394-
href={`#${category.toLowerCase()}`}
395-
class="l-float-button"
396-
>
397-
<span>Show more</span>
398-
</Button>
399392
</div>
400393
</section>
401394
{/if}

β€Žsrc/routes/integrations/flutterflow-auth-kit/+page.markdocβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ layout: integration
33
title: Auth Kit for FlutterFlow
44
description: Integrate Appwrite Auth into your FlutterFlow apps without writing complex code
55
date: 2024-03-01
6-
featured: true
6+
featured: false
77
isPartner: true
88
isNew: true
99
cover: /images/integrations/flutterflow-auth-kit/cover.png
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
layout: integration
3+
title: OAuth with X
4+
description: Authenticate users with an existing X account
5+
date: 2026-04-09
6+
featured: true
7+
isPartner: true
8+
isNew: true
9+
cover: /images/integrations/oauth-x/cover.png
10+
category: auth
11+
product:
12+
avatar: '/images/integrations/avatars/x.png'
13+
vendor: X
14+
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.'
15+
platform:
16+
- 'Cloud'
17+
images:
18+
- /images/integrations/oauth-x/cover.png
19+
- /images/integrations/oauth-x/new-app.png
20+
- /images/integrations/oauth-x/oauth2.png
21+
- /images/integrations/oauth-x/provider.png
22+
---
23+
24+
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.
25+
26+
# How does the integration work?
27+
28+
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.
29+
30+
# How to implement
31+
32+
To implement the X OAuth adapter in Appwrite Auth, there are several steps you must complete:
33+
34+
## Step 1: Create an X Developer app
35+
36+
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.
37+
38+
In your app's settings, scroll down to **User authentication settings** and click **Set up**. Configure the following:
39+
40+
- **App permissions**: Select **Read** at minimum.
41+
- **Type of App**: Select **Web App, Automated App or Bot**.
42+
- **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.
43+
44+
![OAuth 2.0 settings](/images/integrations/oauth-x/oauth2.png)
45+
46+
After saving, X will display a **Client ID** and **Client Secret**. Save both values for later use.
47+
48+
## Step 2: Add X OAuth adapter to your Appwrite project
49+
50+
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.
51+
52+
![X provider](/images/integrations/oauth-x/provider.png)
53+
54+
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.
55+
56+
## Step 3: Test the provider
57+
58+
Follow the [OAuth 2 login](/docs/products/auth/oauth2#init) flow to test your provider.
59+
60+
# Read more about X and Appwrite Auth
61+
62+
If you would like to learn more about X and Appwrite Auth, we have some resources that you should visit:
63+
64+
- [X Developer Console](https://console.x.com)
65+
- [Implement OAuth login in your apps using Appwrite Auth](/docs/products/auth/oauth2)
66+
- [Understanding OAuth and OpenID Connect](/blog/post/oauth-openid)
67+
- [Appwrite Auth API reference](/docs/references/cloud/client-web/account)
-1.23 MB
Loading
-2.18 MB
Loading
-1.26 MB
Loading
-693 KB
Loading
-713 KB
Loading

0 commit comments

Comments
Β (0)