mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-17 18:58:33 +00:00
twitter: retry if possibly missing csrf token
This commit is contained in:
parent
6c33687279
commit
ec4a8c1e3e
@ -83,6 +83,16 @@ const requestTweet = async(tweetId, token, cookie) => {
|
||||
let result = await fetch(graphqlTweetURL, { headers });
|
||||
updateCookie(cookie, result.headers);
|
||||
|
||||
// we might have been missing the `ct0` cookie, retry
|
||||
if (result.status === 403 && result.headers.get('set-cookie')) {
|
||||
result = await fetch(graphqlTweetURL, {
|
||||
headers: {
|
||||
...headers,
|
||||
'x-csrf-token': cookie.values().ct0
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user