itd*_*ork 3 python oauth auth0
我正在尝试使用 Auth0 进行身份验证并获取用户数据。
import json
import requests
payload = {
'grant_type': 'password',
'username': '********',
'password': '********',
'client_id': '********',
'connection': 'Username-Password-Authentication',
'scope': 'openid'
# 'scope': 'openid, read:clients, read:client_keys'
# 'scope': 'read:clients'
}
base = 'https://********.auth0.com'
url = base + '/oauth/ro'
response = requests.post(url, data=payload)
response = json.loads(response.content)
headers = {"Authorization": "bearer " + response["id_token"]}
response = requests.get(base + '/api/v2/clients/joebloggs', headers=headers).json()
print response
Run Code Online (Sandbox Code Playgroud)
我不断得到的是
{u'errorCode': u'insufficient_scope', u'message': u'Insufficient scope, expected any of: read:clients,read:client_keys', u'error': u'Forbidden', u'statusCode': 403}
Run Code Online (Sandbox Code Playgroud)
究竟有什么问题,该怎么办?
您不能id_token对 Auth0 API 使用 。您需要 API (v2) 的特定令牌(在您的情况下,您需要一个read:client范围)。请参阅此处:https : //auth0.com/docs/api/management/v2
| 归档时间: |
|
| 查看次数: |
3130 次 |
| 最近记录: |