Auth0 Home Blog Docs

Authorization extension - Unauthorized

authorization-extens
extensions

#1

Hello. I’ve been trying some functionalities of Auth0 and I’m having some problems with Authorization Extension. I want to use the Authorization Extension to manage groups, roles and permissions. But no matter what I do, I always receive “Unauthorized” as answer. You can see my code in Python below:

import http.client

conn = http.client.HTTPSConnection("<name>.auth0.com")

payload = "{\"client_id\":\"<client_id>\",\"client_secret\":\"<client_secret>\",\"audience\":\"urn:auth0-authz-api\",\"grant_type\":\"client_credentials\"}"

headers = { 'content-type': "application/json" }

conn.request("POST", "/oauth/token", payload, headers)

res = conn.getresponse()
data = res.read()
data_dict = eval(data.decode("utf-8"))


headers = { 'authorization': "Bearer "+ data_dict['access_token']}

conn.request("GET", "/api/groups", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

Could someone help me? Thanks in advance