-
-
Notifications
You must be signed in to change notification settings - Fork 975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bluesky authentication error: InvalidToken: Unexpected authorization type #6134
Comments
@mikf Still seeing this. Looks like:
It is clearly sending a basic auth token, and it's the same one that worked in the resolveHandle call. But it's also the token from createSession. Is it the wrong one? I can also confirm this isn't a netrc issue, as passing an explicit --username and --password gives the same result. |
A little debugging: diff --git a/gallery_dl/extractor/bluesky.py b/gallery_dl/extractor/bluesky.py
index de5d0c6f..7147df0a 100644
--- a/gallery_dl/extractor/bluesky.py
+++ b/gallery_dl/extractor/bluesky.py
@@ -446,6 +446,7 @@ class BlueskyAPI():
def authenticate(self):
self.headers["Authorization"] = self._authenticate_impl(self.username)
+ self.log.info("Implicit authorization value is %s", self.headers["Authorization"])
@cache(maxage=3600, keyarg=1)
def _authenticate_impl(self, username):
@@ -483,9 +484,12 @@ class BlueskyAPI():
while True:
self.authenticate()
+ self.log.info("Calling request with authorization %s", self.headers["Authorization"])
response = self.extractor.request(
url, params=params, headers=self.headers, fatal=None)
+ self.log.info("The actual headers sent were %s", response.request.headers)
+
if response.status_code < 400:
return response.json()
if response.status_code == 429: With this patch applied, the problem is apparent:
See that the "authenticated" call is using the basic authorization token, not the explicitly passed bearer auth header! Something is wrong with |
OK. I spent my whole day digging into this, but I've found a way to fix this. #6455 |
Your version of gallery-dl is sending an
This does not happen with vanilla settings or code. The only way this and all the other |
I agree that this is what's happening, but according to every metric I know, gallery-dl is doing this. I am invoking the local module with {
"extractor": {
"twitter": {
"cookies": "<path>",
"logout": true
}
}
} gallery-dl starts passing a basic token to requests as early as
I can try to identify exactly why this is happening, but everything I see tells me this is vanilla behavior. |
There is no
|
Requests is doing it because there's a netrc value set for bsky.social. Tracing the initial login request: https://github.com/mikf/gallery-dl/blob/master/gallery_dl/extractor/common.py#L172 https://github.com/psf/requests/blob/main/src/requests/sessions.py#L575 https://github.com/psf/requests/blob/main/src/requests/sessions.py#L478-L481 https://github.com/psf/requests/blob/main/src/requests/sessions.py#L498 {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0', 'Accept': '*/*', 'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate, br', 'Referer': 'https://bsky.app/'}
{'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0', 'Accept': '*/*', 'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate, br', 'Referer': 'https://bsky.app/', 'Content-Type': 'application/json', 'Content-Length': '64', 'Authorization': 'Basic TOKEN'} Temporarily removing my bsky.social netrc entry works around the problem, even on origin/master. |
Wow, now that's something I would have never expected. Good find. I'll probably add an option to disable requests' |
Should be fixed with 0a72a50 by preventing |
I'm experiencing authentication issues in bluesky very similar to #5780, except that clearing the cache doesn't resolve the problem.
Authentication is defined in netrc.
The text was updated successfully, but these errors were encountered: