20 };
21
22 return fetchJSON(`https://api.val.town/v1/vals/${valId}`, {
23 headers: {
24 Authorization: `Bearer ${token}`,
14 };
15
16 return fetchJSON("https://api.val.town/v1/vals", {
17 headers: {
18 Authorization: `Bearer ${token}`,
35 </li>
36 <li>If your access token expires, we use the refresh token to get a new one.</li>
37 <li>Use your access token to make requests to the Spotify API.</li>
38 </ol>
39
1Migrated from folder: External_APIs/spotify/spotify_helpers
3
4export let spotifyRefreshToken = async ({ refresh_token, client_id, client_secret }) =>
5 fetchJSON("https://accounts.spotify.com/api/token", {
6 method: "POST",
7 body: await querystring({
1Migrated from folder: External_APIs/spotify/spotify
6 return (post_id) => {
7 // logMessage( "debug", `constructReadTangleUrl called with post_id: ${post_id}`, );
8 const baseUrl = new URL("https://www.readtangle.com/members/api/comments/?filter=post_id%3A");
9 let commentUrl = "";
10 if (typeof post_id === "string") {
20
21async function getNewThreads() {
22 const resp = await fetch(`https://discord.com/api/guilds/${guild}/threads/active`, {
23 headers: {
24 "Authorization": `Bot ${token}`,
19 <article>
20 <form method="post">
21 <label for="token">API Token</label>
22 <input id="token" name="token" type="password" />
23 <button type="submit">Submit</button>
47
48async function fetchUser(token: string): Promise<User> {
49 const resp = await fetch("https://api.val.town/v1/me", {
50 headers: {
51 Authorization: `Bearer ${token}`,
9## Usage
10
11Set an `AUTH_SECRET_KEY` env variable (used to sign/verify jwt tokens). Use an API token to authenticate.
12
13```typescript
23See @pomdtr/test_auth for an example
24
25⚠️ Make sure to only provides your api token to vals you trust (i.e. your own), as it gives access to your whole account.
26
27Migrated from folder: Archive/auth_middleware