Python Auth0 - 示例脚本未经授权

Python Auth0 - example script not authorized

需要枚举用户,我正在使用位于此处的 auth0 客户端 - https://github.com/auth0/auth0-python

我已经设置了一个示例应用程序,并确保它具有客户端凭据授权类型。通过示例,尝试 运行 以下 . . . .

        get_token = GetToken(domain)
    token = get_token.client_credentials(non_interactive_client_id,
                                         non_interactive_client_secret, 'https://{}/api/v2/'.format(domain))
    mgmt_api_token = token['access_token']

    auth0 = Auth0(domain, mgmt_api_token)

    conns = auth0.connections.all()
    return conns

但是在 .client_credentials,我失败了。 ..

auth0.v3.exceptions.Auth0Error: 403: Client is not authorized to access "https://MY_DOMAIN/api/v2/". You might probably want to create a "client-grant" associated to this API. 

有与错误相关的文档,但它是 404。

SDK 正在使用 non_interactive_client_id 作为客户端 ID,通过客户端凭据授予使用管理 API。

您看到的错误是 Auth0 告诉您 特定客户端 ID 无权使用 API.

管理 API 是您可以在 "APIs" 下的 Auth0 仪表板中找到的资源(不确定,但还有一个很深的 link,例如 manage.auth0.com/#/apis/management) .那里有一个选项卡,应该显示类似 "Non Interactive Clients" 的内容,您将在其中看到所有客户的列表并切换以授予他们访问 API.

授予对 API(以及所需范围)的访问权限后,您的操作应该可以正常进行。