2016-06-28 8 views
1

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 

は正確に間違っている、それについて何をすべきかどう

{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} 

のですか?

答えて

2

Auth0 APIにはid_tokenを使用できません。 API(v2)には特定のトークンが必要です(場合によってはread:clientスコープが必要です)。参照:https://auth0.com/docs/api/management/v2

関連する問題