Skip to content

Commit 1c9b72a

Browse files
committed
fix: use alternate bearer token in several other endpoints known to use it
1 parent 64164a5 commit 1c9b72a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/trends.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { addApiParams, requestApi } from './api';
1+
import { addApiParams, requestApi, bearerToken2 } from './api';
22
import { TwitterAuth } from './auth';
33
import { TimelineV1 } from './timeline-v1';
44

@@ -11,9 +11,14 @@ export async function getTrends(auth: TwitterAuth): Promise<string[]> {
1111
params.set('include_page_configuration', 'false');
1212
params.set('entity_tokens', 'false');
1313

14+
// Use bearerToken2 for trends endpoint
1415
const res = await requestApi<TimelineV1>(
1516
`https://api.x.com/2/guide.json?${params.toString()}`,
1617
auth,
18+
'GET',
19+
undefined,
20+
undefined,
21+
bearerToken2,
1722
);
1823
if (!res.success) {
1924
throw res.err;

src/tweets.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,14 @@ export async function fetchTweets(
121121
userTweetsRequest.variables['cursor'] = cursor;
122122
}
123123

124+
// Use bearerToken2 for UserTweets endpoint
124125
const res = await requestApi<TimelineV2>(
125126
userTweetsRequest.toRequestUrl(),
126127
auth,
128+
'GET',
129+
undefined,
130+
undefined,
131+
bearerToken2,
127132
);
128133

129134
if (!res.success) {
@@ -374,9 +379,15 @@ export async function getTweet(
374379
const tweetDetailRequest = apiRequestFactory.createTweetDetailRequest();
375380
tweetDetailRequest.variables.focalTweetId = id;
376381

382+
// Use bearerToken2 for this specific endpoint (TweetDetail)
383+
// This is required for animated GIFs to appear in tweets with mixed media
377384
const res = await requestApi<ThreadedConversation>(
378385
tweetDetailRequest.toRequestUrl(),
379386
auth,
387+
'GET',
388+
undefined,
389+
undefined,
390+
bearerToken2,
380391
);
381392

382393
if (!res.success) {

0 commit comments

Comments
 (0)