@@ -35,33 +35,41 @@ URL this view will respond to:
3535.. code-block :: python
3636
3737 from django.conf.urls import patterns, url
38- from oauth2_provider import views
38+ import oauth2_provider.views as oauth2_views
3939 from django.conf import settings
4040 from .views import ApiEndpoint
4141
42- urlpatterns = patterns(
43- ' ' ,
44- url(r ' ^ admin/' , include(admin.site.urls)),
45-
46- # OAuth2 provider endpoints
47- url(r ' ^ o/authorize/$ ' , views.AuthorizationView.as_view(), name = " authorize" ),
48- url(r ' ^ o/token/$ ' , views.TokenView.as_view(), name = " token" ),
49- url(r ' ^ o/revoke-token/$ ' , views.RevokeTokenView.as_view(), name = " revoke-token" ),
50-
51- url(r ' ^ api/hello' , ApiEndpoint.as_view()), # a resource endpoint
52- )
42+ # OAuth2 provider endpoints
43+ oauth2_endpoint_views = [
44+ url(r ' ^ authorize/$ ' , oauth2_views.AuthorizationView.as_view(), name = " authorize" ),
45+ url(r ' ^ token/$ ' , oauth2_views.TokenView.as_view(), name = " token" ),
46+ url(r ' ^ revoke-token/$ ' , oauth2_views.RevokeTokenView.as_view(), name = " revoke-token" ),
47+ ]
5348
5449 if settings.DEBUG :
55- # OAuth2 Application management views
56-
57- urlpatterns += patterns(
58- ' ' ,
59- url(r ' ^ o/applications/$ ' , views.ApplicationList.as_view(), name = " application-list" ),
60- url(r ' ^ o/applications/register/$ ' , views.ApplicationRegistration.as_view(), name = " application-register" ),
61- url(r ' ^ o/applications/( ?P<pk> \d + ) /$ ' , views.ApplicationDetail.as_view(), name = " application-detail" ),
62- url(r ' ^ o/applications/( ?P<pk> \d + ) /delete/$ ' , views.ApplicationDelete.as_view(), name = " application-delete" ),
63- url(r ' ^ o/applications/( ?P<pk> \d + ) /update/$ ' , views.ApplicationUpdate.as_view(), name = " application-update" ),
64- )
50+ # OAuth2 Application Management endpoints
51+ oauth2_endpoint_views += [
52+ url(r ' ^ applications/$ ' , oauth2_views.ApplicationList.as_view(), name = " list" ),
53+ url(r ' ^ applications/register/$ ' , oauth2_views.ApplicationRegistration.as_view(), name = " register" ),
54+ url(r ' ^ applications/( ?P<pk> \d + ) /$ ' , oauth2_views.ApplicationDetail.as_view(), name = " detail" ),
55+ url(r ' ^ applications/( ?P<pk> \d + ) /delete/$ ' , oauth2_views.ApplicationDelete.as_view(), name = " delete" ),
56+ url(r ' ^ applications/( ?P<pk> \d + ) /update/$ ' , oauth2_views.ApplicationUpdate.as_view(), name = " update" ),
57+ ]
58+
59+ # OAuth2 Token Management endpoints
60+ oauth2_endpoint_views += [
61+ url(r ' ^ authorized-tokens/$ ' , oauth2_views.AuthorizedTokensListView.as_view(), name = " authorized-token-list" ),
62+ url(r ' ^ authorized-tokens/( ?P<pk> \d + ) /delete/$ ' , oauth2_views.AuthorizedTokenDeleteView.as_view(),
63+ name = " authorized-token-delete" ),
64+ ]
65+
66+ urlpatterns = [
67+ # OAuth 2 endpoints:
68+ url(r ' ^ o/' , include(oauth2_endpoint_views, namespace = " oauth2_provider" )),
69+
70+ url(r ' ^ admin/' , include(admin.site.urls)),
71+ url(r ' ^ api/hello' , ApiEndpoint.as_view()), # an example resource endpoint
72+ ]
6573
6674 You will probably want to write your own application views to deal with permissions and access control but the ones packaged with the library can get you started when developing the app.
6775
0 commit comments