django - 正确集成 Django Oauth Toolkit url

标签 django django-oauth

我按照官方 django-oauth 工具包文档 ( https://django-oauth-toolkit.readthedocs.io/en/latest/tutorial/tutorial_02.html ) 的说明进行操作,并手动包含所有 oauth-toolkit url 以防止用户创建应用程序。

在我的根 urls.py 中,我将以下行添加到 url 模式中,如教程中所示:

url(r'^o/', include(oauth2_endpoint_views, namespace="oauth2_provider")),

我使用了 django.conf.url 包中的 include

现在当我启动服务器时,它说

“不支持在 include() 中指定命名空间而不提供 app_name。在包含的模块中设置 app_name 属性,或传递包含模式列表和 app_name 的 2 元组。”

当我向 url 命令添加 name 属性时,如下所示:

url(r'^o/', include(oauth2_endpoint_views, namespace="oauth2_provider"), name="oauth2_provider"),

服务器启动,但是当我尝试访问“localhost/o/applications”时,它显示“NoReverseMatch:'oauth2_provider'不是注册的命名空间”

我做错了什么?

最佳答案

尝试

 url(r'^o/', include(('oauth2_provider.urls', 'oauth2_provider_app', ), namespace='oauth2_provider'), ),

引用oauth2_provider

关于django - 正确集成 Django Oauth Toolkit url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48950959/

相关文章:

django - uWSGI不会重新加载、重新启动或让我运行服务

django - 使用pytest测试django模型字段的max_length

django - 自定义 Django 管理 TabularInline 默认字段

python - Django OAuth 工具包 - 注册用户

django - 如何使用django检查表中是否已存在数据

javascript - 具有多个允许主机的 Django 和 CORS 策略

django - 无法为 API 设置 'oauth2_provider.ext.rest_framework.OAuth2Authentication' 导入 'DEFAULT_AUTHENTICATION_CLASSES'

Django-OAuth-ToolKit : Generating access token's for multiple resources/services using client credentials grant type of OAuth2. 0

django-rest-framework - “type”对象不可使用 Django Rest Framework 和 django oauth2-toolkit 进行迭代