Skip to content

Commit dbc4702

Browse files
authored
Merge pull request #379 from poswald/docs-application-urls
Change documentation for the Application urls
2 parents c6bf50b + fb5cda0 commit dbc4702

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

docs/advanced_topics.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ That's all, now Django OAuth Toolkit will use your model wherever an Application
5555
Skip authorization form
5656
=======================
5757

58-
Depending on the OAuth2 flow in use and the access token policy, users might be prompted for the
59-
same authorization multiple times: sometimes this is acceptable or even desiderable but other it isn't.
60-
To control DOT behaviour you can use `approval_prompt` parameter when hitting the authorization endpoint.
58+
Depending on the OAuth2 flow in use and the access token policy, users might be prompted for the
59+
same authorization multiple times: sometimes this is acceptable or even desirable but other times it isn't.
60+
To control DOT behaviour you can use the `approval_prompt` parameter when hitting the authorization endpoint.
6161
Possible values are:
6262

6363
* `force` - users are always prompted for authorization.

docs/contributing.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ of the pull request.
4747
Pull upstream changes into your fork regularly
4848
==============================================
4949

50-
It's a good practice to pull upstream changes from master into your fork on a regular basis, infact if you work on
50+
It's a good practice to pull upstream changes from master into your fork on a regular basis, in fact if you work on
5151
outdated code and your changes diverge too far from master, the pull request has to be rejected.
5252

5353
To pull in upstream changes::
@@ -85,7 +85,7 @@ Add the tests!
8585
--------------
8686

8787
Whenever you add code, you have to add tests as well. We cannot accept untested code, so unless it is a peculiar
88-
situation you previously discussed with the core commiters, if your pull request reduces the test coverage it will be
88+
situation you previously discussed with the core committers, if your pull request reduces the test coverage it will be
8989
**immediately rejected**.
9090

9191
Code conventions matter

docs/tutorial/tutorial_02.rst

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,44 @@ URL this view will respond to:
3434

3535
.. code-block:: python
3636
37+
from django.conf.urls import patterns, url
38+
import oauth2_provider.views as oauth2_views
39+
from django.conf import settings
3740
from .views import ApiEndpoint
3841
39-
urlpatterns = patterns(
40-
'',
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+
]
48+
49+
if settings.DEBUG:
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+
4170
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!
44-
)
71+
url(r'^api/hello', ApiEndpoint.as_view()), # an example resource endpoint
72+
]
73+
74+
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.
4575

4676
Since we inherit from `ProtectedResourceView`, we're done and our API is OAuth2 protected - for the sake of the lazy
4777
programmer.
@@ -51,7 +81,7 @@ Testing your API
5181
Time to make requests to your API.
5282

5383
For a quick test, try accessing your app at the url `/api/hello` with your browser
54-
and verify that it reponds with a `403` (in fact no `HTTP_AUTHORIZATION` header was provided).
84+
and verify that it responds with a `403` (in fact no `HTTP_AUTHORIZATION` header was provided).
5585
You can test your API with anything that can perform HTTP requests, but for this tutorial you can use the online
5686
`consumer client <http://django-oauth-toolkit.herokuapp.com/consumer/client>`_.
5787
Just fill the form with the URL of the API endpoint (i.e. http://localhost:8000/api/hello if you're on localhost) and

0 commit comments

Comments
 (0)