Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

init_poolmanager() got an unexpected keyword argument 'block' #4

Closed
noiano opened this Issue May 21, 2013 · 8 comments

Comments

Projects
None yet
2 participants

noiano commented May 21, 2013

After having authorized the app I get this:

noiano@noiano-Inspiron-1720:~$ skydrive-cli tree
Traceback (most recent call last):
File "/usr/local/bin/skydrive-cli", line 9, in
load_entry_point('python-skydrive==13.03.26', 'console_scripts', 'skydrive-cli')()
File "/usr/local/lib/python2.7/dist-packages/skydrive/cli_tool.py", line 319, in main
res = {api.info(root_id)['name']: recurse(root_id)}
File "/usr/local/lib/python2.7/dist-packages/skydrive/cli_tool.py", line 313, in recurse
for obj in api.listdir(obj_id):
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 405, in listdir
lst = super(SkyDriveAPI, self).listdir(folder_id=folder_id, limit=limit)['data']
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 270, in listdir
return self(join(folder_id, 'files'), dict(limit=limit))
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 257, in call
self.auth_get_token()
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 431, in auth_get_token
ret = super(PersistentSkyDriveAPI, self).auth_get_token(_argz, *_kwz)
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 179, in auth_get_token
res = self.auth_access_data_raw = self._auth_token_request()
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 201, in _auth_token_request
return self.request(self.auth_url_token, method='post', data=post_data)
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 88, in request
patched_session = self._requests_tls_workarounds(requests)
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 74, in _requests_tls_workarounds
session.mount('https://', TLSv1Adapter())
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 81, in init
self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block)
TypeError: init_poolmanager() got an unexpected keyword argument 'block'

Owner

mk-fg commented May 21, 2013

Ah, yes, apparently requests.adapters.HTTPAdapter api changed a bit in requests/requests@2eb6826, adding "block" keyword.

Should be fixed in 583acb6 (or the latest pypi package, just pushed), please try it.

noiano commented May 21, 2013

I'm trying to run pip install -U python-skydrive but I still get the same error ...

noiano commented May 21, 2013

now I get bad request error

File "/usr/local/bin/skydrive-cli", line 9, in
load_entry_point('python-skydrive==13.05.1', 'console_scripts', 'skydrive-cli')()
File "/usr/local/lib/python2.7/dist-packages/skydrive/cli_tool.py", line 249, in main
api.auth_get_token()
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 438, in auth_get_token
ret = super(PersistentSkyDriveAPI, self).auth_get_token(_argz, *_kwz)
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 186, in auth_get_token
res = self.auth_access_data_raw = self._auth_token_request()
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 208, in _auth_token_request
return self.request(self.auth_url_token, method='post', data=post_data)
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 128, in request
raise raise_for.get(code, ProtocolError)(code, err.message)
skydrive.api_v5.ProtocolError: (400, '400 Client Error: Bad Request')

Owner

mk-fg commented May 21, 2013

So the fix works, great.

About authentication error - it's from the server, and given that it's from the first api.auth_get_token() call, I think it either rejects your auth credentials (though not sure if it should be 401/403 in that case), or, given that it's from cli tool, maybe configuration file contains some errors - while clean, YAML isn't the most user-friendly format and has some subtle pitfalls - I'd suggest checking the config vs the README examples first and re-checking that you followed all the instructions there.

You can also use --debug option to get more info about requests the tool makes (though I don't think there'd be much extra info wrt to auth - it's mostly in the POST body iirc), but don't see any indication that you really need to look there.

@mk-fg mk-fg closed this May 21, 2013

noiano commented May 21, 2013

The configuration is ok I guess, otherwise I would get auth errors or parsing errors... here's the debug

noiano@noiano-Inspiron-1720:~$ skydrive-cli --debug quota
DEBUG:skydrive.api_v5:Requesting new access_token through authorization_code grant
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): login.live.com
DEBUG:requests.packages.urllib3.connectionpool:"POST /oauth20_token.srf HTTP/1.1" 400 214
Traceback (most recent call last):
File "/usr/local/bin/skydrive-cli", line 9, in
load_entry_point('python-skydrive==13.05.1', 'console_scripts', 'skydrive-cli')()
File "/usr/local/lib/python2.7/dist-packages/skydrive/cli_tool.py", line 253, in main
df, ds = map(size_units, api.get_quota())
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 405, in get_quota
(super(SkyDriveAPI, self).get_quota())
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 273, in get_quota
return self('me/skydrive/quota')
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 264, in call
self.auth_get_token()
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 438, in auth_get_token
ret = super(PersistentSkyDriveAPI, self).auth_get_token(_argz, *_kwz)
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 186, in auth_get_token
res = self.auth_access_data_raw = self._auth_token_request()
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 208, in _auth_token_request
return self.request(self.auth_url_token, method='post', data=post_data)
File "/usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py", line 128, in request
raise raise_for.get(code, ProtocolError)(code, err.message)
skydrive.api_v5.ProtocolError: (400, '400 Client Error: Bad Request')

Owner

mk-fg commented May 21, 2013

As you seem to have ran "auth" on pre-last backtrace, and re-using the code it put into the config in the last one, I'd think that error-400 would just mean that the auth-code has expired.
I don't recall what's the time limit for skydrive (might be in the docs), but it's ridiculously short for some services - e.g. just 30 seconds (and it's documented) for box.net once you click "authorize app" - so definitely re-try the whole "auth" step (it should overwrite the code it put into config), not re-use the same auth-code.

Errors are definitely "meeeeh" with skydrive - you can get 400 for pretty much anything, so unless you know it should be "auth errors" (assuming you mean 401 or 403), I wouldn't speculate on what it really means.
It can also potentially mean unset "mobile app" (or whatever it's called) flag in the app settings.

Ruling out all of the above, try installing the module from "debug_requests_data" branch I just pushed - simpliest way would be to put this file to /usr/local/lib/python2.7/dist-packages/skydrive/api_v5.py on your system.

It has an extra log.debug() line to dump all the data that goes into request body, then (re-)run skydrive-cli --debug auth <url>.
It should print line like this: "DEBUG:skydrive.api_v5:Request data: {u'headers': {}, u'data': {'redirect_uri': u'https://login.live.com/oauth20_desktop.srf', 'code': 'xxx', 'client_id': 'yyy', 'client_secret': 'zzz', 'grant_type': u'authorization_code'}}" (json)
Make sure all the same keys as presented above are present in your line as well ("code", "client_id", etc).
If not, paste it here, but take care to replace or truncate the code and/or client_secret at least.

noiano commented May 22, 2013

I re-authorized the script and now it works :)

Owner

mk-fg commented May 22, 2013

Ah, glad it was resolved and still works, guess I'll put something about auth error-400 and timeout into the README.
Thanks for pointing these two out ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment