You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `.loginWithOAuth2()` method already returns a logged client, but if you want to create an instance by yourself with an access token (for example to use your refresh token), use it as a **Bearer token**.
Copy file name to clipboardExpand all lines: doc/examples.md
+19-1Lines changed: 19 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,11 +15,14 @@ For each implemented endpoint, you have a link to documentation available in JSD
15
15
16
16
### With user credentials (act as a logged user)
17
17
18
-
This kind of auth is needed for endpoint mentionned with `"OAuth 1.0a User context"` in Twitter documentation.
18
+
This kind of auth is needed for endpoint mentionned with `"OAuth 1.0a User context"`or `"OAuth 2.0 Authorization Code with PKCE"`in Twitter documentation.
19
19
Usually, this is used to act on behalf of a user.
20
20
21
21
Access token and access secret are obtained through [the 3-legged auth flow](./auth.md).
22
22
23
+
- OAuth 1.0a User context
24
+
25
+
This authentification method requires to use a couple of 4 keys, 2 are your app keys and 2 are obtained with the 3-legged auth flow.
23
26
```ts
24
27
const client =newTwitterApi({
25
28
appKey: '<YOUR-TWITTER-APP-TOKEN>',
@@ -30,6 +33,21 @@ const client = new TwitterApi({
30
33
// NOTE: accessToken and accessSecret are not required if you want to generate OAuth login links.
31
34
```
32
35
36
+
- OAuth 2.0 Authorization Code with PKCE
37
+
38
+
This authentification method only requires to use the obtained **access token** with the 3-legged OAuth2 auth flow.
If your access token is no longer valid, but your have a refresh token (you specified `offline.access` in scope array), you can ask for a new access token with your client keys:
0 commit comments