Public
Script
October 23, 2023
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