This repository has been archived by the owner on Mar 30, 2023. It is now read-only.
Fix RefreshTokenException('Could not find the Guest token in HTML') #1322
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About the problem
This problem has recently begun to occur on some environments.
This doesn't happen every time, so if you are lucky, you don't get the error.
The cause is literally that twint could not find the Guest token in HTML.
Actually, sometimes token isn't included in HTML recently.
twint require the result of running the above code is
})();</script><script nonce="VALUE">document.cookie = decodeURIComponent("gt=VALUE; Max-Age=VALUE; Domain=.twitter.com; Path=/; Secure");</script>
.However, sometimes the result is only
})();</script>
and missing theGuest token.
About the solution
In this patch, twint get the Guest token from https://api.twitter.com/1.1/guest/activate.json if could not find the one.
The author referred to the code of gallery-dl.
Author's note:
This commit was adopted from #1320 (comment) by @minamotorin.
Closes #1320.