Assigning scopes to a resource server created by Auth0 Manager API

I whant to create a resource server of Auth0 using the Auth0 Manager API https://auth0.com/docs/api/management/v2#!/Resource_Servers/post_resource_servers

Works all fine, but when i whant to create a a resource server defining the field scopes get error, because scopes receives a type array[object]

Now the cuestion is, how get an object of scopes?, y can’t create an object scope.

Try this, but not work:

"scopes": [{"name":"read:data", "description":"some description"}]

and this:

"scopes": [{"permission":"read:data", "description":"some description"}]

Snipet of code:

from auth0.v3.management import Auth0

auth0 = Auth0(domain, token)

data = {
    "name": 'somename',
    "identifier": 'somename',
    "signing_alg": 'RS256',
    "allow_offline_access": True,
    "token_lifetime": 91234,
    "skip_consent_for_verifiable_first_party_clients": True,
    "scopes": [{"name":"read:data", "description":"some description"}]
}

try:
    status = auth0.resource_servers.create(body=data)
    print '\nAPI CREATED CORRECTLY\n'
except Exception as e:
    print '\nAPI ERROR CREATING RESOURCE SERVER!!'
    print e

All the other fields works fine, the only that give me problems is scopes .

the key is value and not name or permission, just like this:

[{"value":"read:data", "description":"some description"}]
2 Likes

Glad you were able to figure it out and really appreciate you shared it with the community!

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.