Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
solojungle authored Oct 29, 2024
1 parent 7ed74a6 commit e09ae73
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,19 @@ Exchange the authorization code for an access token:

```typescript
const code = 'AUTHORIZATION_CODE';
const tokenResponse = await threadsAPI.getAccessToken(code);
console.log('Access Token:', tokenResponse.access_token);

// Set the access token for future requests
threadsAPI.setAccessToken(tokenResponse.access_token);
// Get the short lived token
const { access_token: shortLivedToken } = await threads.getAccessToken(code);
// Convert the short lived token to a long term access token
const { access_token: accessToken, expires_in: expiresIn } = await threads.getLongLivedToken(shortLivedToken);

// Store the access token in your db

// Now we can do stuff like get the User profile
const profile = await threads.getUserProfile({
userId: "me",
fields: ["id", "username", "name", "threads_profile_picture_url"],
});
```

### Creating and Publishing a Thread
Expand Down

0 comments on commit e09ae73

Please sign in to comment.