Reputation: 31
I am trying to authnticate with Auth0 and get user data.
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
What I keep getting is
{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}
What exactly is wrong and what to do about it?
Upvotes: 3
Views: 5962
Reputation: 14212
You cannot use an id_token
for the Auth0 API. You need a specific token for the API (v2) (and in your case you need a read:client
scope). See here: https://auth0.com/docs/api/management/v2
Upvotes: 5