使用jupyterhub授权令牌失败

时间:2017-08-03 08:49:55

标签: jupyter jupyterhub

我有一个正在运行的jupyterhub服务,我希望使用管理员权限与REST API进行交互。

文档建议我可以获得这样的授权令牌,其中username是管理员用户:

$ jupyterhub token --config=<path-to-config> <username>
f9ed5a19d62d4285bbebe2ded9028baf

但是,如果我在对API的请求中使用此令牌,则会失败:

>>> t1 = 'f9ed5a19d62d4285bbebe2ded9028baf'
>>> requests.get('http://myjupyterhub/hub/api/users', headers={'Authorization': 'token {}'.format(t1)})
>>> <Response [403]>

如果我有用户密码,我可以获得一个令牌,但这在我的场景中不方便:

>>> r = requests.post('http://myjupyterhub/hub/api/authorizations/token', json={'username': 'myadmin', 'password': myadminpass})
>>> t2 = r.json()['Authentication']
>>> requests.get('http://myjupyterhub/hub/api/users', headers={'Authorization': 'token {}'.format(t2)})
>>> <Response [200]>

我误解了jupyterhub token是如何运作的吗?

0 个答案:

没有答案
相关问题