Search code examples
djangodjango-oauth

Integrate Django Oauth Toolkit urls correctly


I followed the instructions from the official django-oauth toolkit doc (https://django-oauth-toolkit.readthedocs.io/en/latest/tutorial/tutorial_02.html) and included all oauth-toolkit urls manually to prevent users from creating applications.

In my root urls.py i added the following line to the url patterns, as showed in the tutorial:

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

I used the include from django.conf.url package.

Now when i start the server, it says

"Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead."

when i add a name attribute to the url-command like this:

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

the server starts up, but when i try to visit "localhost/o/applications" it says "NoReverseMatch: 'oauth2_provider' is not a registered namespace"

What am i doing wrong?


Solution

  • Try

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

    Refer oauth2_provider