首页 > 解决方案 > 将范围分配给由 Auth0 Manager API 创建的资源服务器

问题描述

我想使用 Auth0 管理器 API https://auth0.com/docs/api/management/v2#!/Resource_Servers/post_resource_servers创建 Auth0 的资源服务器

一切正常,但是当我想创建定义字段范围的资源服务器时会出错,因为范围接收类型数组 [对象]

现在的问题是,如何获取范围对象?,我无法创建对象范围。

试试这个,但不起作用:

"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

标签: auth0

解决方案


试试这种格式:

"scopes": [
      {
        "description": "Read Client Grants",
        "value": "read:client_grants"
      },
      {
        "description": "Create Client Grants",
        "value": "create:client_grants"
      }
]

推荐阅读