Skip to content

Commit 06378b5

Browse files
committed
Don't encourage adding the application urls without dealing security restrictions
1 parent f28496c commit 06378b5

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

docs/tutorial/tutorial_02.rst

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,37 @@ URL this view will respond to:
3434

3535
.. code-block:: python
3636
37+
from django.conf.urls import patterns, url
38+
from oauth2_provider import views
39+
from django.conf import settings
3740
from .views import ApiEndpoint
3841
3942
urlpatterns = patterns(
4043
'',
4144
url(r'^admin/', include(admin.site.urls)),
42-
url(r'^o/', include('oauth2_provider.urls', namespace='oauth2_provider')), # look ma, I'm a provider!
43-
url(r'^api/hello', ApiEndpoint.as_view()), # and also a resource server!
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
4452
)
4553
54+
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+
)
65+
66+
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.
67+
4668
Since we inherit from `ProtectedResourceView`, we're done and our API is OAuth2 protected - for the sake of the lazy
4769
programmer.
4870

0 commit comments

Comments
 (0)