Readme

Login with Twitter 𝕏

Use this val to login with 𝕏 and save your token into a twitter_token val

Usage

  1. Fork this val
  2. Change the πŸ”’ privacy to "Unlisted"
  3. Navigate to https://developer.twitter.com/en/portal/dashboard to create an OAuth app and save your client id and secret to your secrets page
  4. Navigate to https://{your_username}-twitter.web.val.run to authenticate with 𝕏

And then you'll have your tokens saved to a twitter_token val!

Other Twitter 𝕏 helper vals

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
let { twitter_token } = await import("https://esm.town/v/andreterron/twitter_token");
let { twitter_auth_storage } = await import("https://esm.town/v/andreterron/twitter_auth_storage");
import process from "node:process";
import { twitterAuthHandler } from "https://esm.town/v/andreterron/twitterAuthHandler";
export async function twitter(req: Request) {
// Constants
const username = "YOUR_VALTOWN_USERNAME";
//
const { res, token, storage } = await twitterAuthHandler(req, {
client_id: process.env.twitter_client_id,
client_secret: process.env.twitter_client_secret,
redirect_uri: `https://${username}-twitter.web.val.run/callback`,
scopes: ["tweet.read", "tweet.write", "users.read", "offline.access"],
storage: twitter_auth_storage,
});
//
if (storage) {
twitter_auth_storage = storage;
}
//
if (token) {
twitter_token = token;
}
//
return res;
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023