将范围分配给 Auth0 管理器 API 创建的资源服务器
Assigning scopes to a resource server created by Auth0 Manager API
我想使用 Auth0 管理器创建 Auth0 的资源服务器 API https://auth0.com/docs/api/management/v2#!/Resource_Servers/post_resource_servers
一切正常,但是当我想创建一个定义字段 scopes 的资源服务器时出现错误,因为 scopes 接收类型 array[object]
现在的问题是,如何获取范围对象?我无法创建对象范围。
试试这个,但不行:
"scopes": [{"name":"read:data", "description":"some description"}]
还有这个:
"scopes": [{"permission":"read:data", "description":"some description"}]
代码片段:
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
所有其他字段工作正常,唯一给我带来问题的是 scopes.
试试这个格式:
"scopes": [
{
"description": "Read Client Grants",
"value": "read:client_grants"
},
{
"description": "Create Client Grants",
"value": "create:client_grants"
}
]
我想使用 Auth0 管理器创建 Auth0 的资源服务器 API https://auth0.com/docs/api/management/v2#!/Resource_Servers/post_resource_servers
一切正常,但是当我想创建一个定义字段 scopes 的资源服务器时出现错误,因为 scopes 接收类型 array[object]
现在的问题是,如何获取范围对象?我无法创建对象范围。
试试这个,但不行:
"scopes": [{"name":"read:data", "description":"some description"}]
还有这个:
"scopes": [{"permission":"read:data", "description":"some description"}]
代码片段:
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
所有其他字段工作正常,唯一给我带来问题的是 scopes.
试试这个格式:
"scopes": [
{
"description": "Read Client Grants",
"value": "read:client_grants"
},
{
"description": "Create Client Grants",
"value": "create:client_grants"
}
]