Skip to content

Commit

Permalink
Merge 06378b5 into 7cba4a5
Browse files Browse the repository at this point in the history
  • Loading branch information
poswald committed May 13, 2016
2 parents 7cba4a5 + 06378b5 commit 67d24c7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/advanced_topics.rst
Expand Up @@ -55,9 +55,9 @@ That's all, now Django OAuth Toolkit will use your model wherever an Application
Skip authorization form
=======================

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

* `force` - users are always prompted for authorization.
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing.rst
Expand Up @@ -47,7 +47,7 @@ of the pull request.
Pull upstream changes into your fork regularly
==============================================

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

To pull in upstream changes::
Expand Down Expand Up @@ -85,7 +85,7 @@ Add the tests!
--------------

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

Code conventions matter
Expand Down
28 changes: 25 additions & 3 deletions docs/tutorial/tutorial_02.rst
Expand Up @@ -34,15 +34,37 @@ URL this view will respond to:

.. code-block:: python
from django.conf.urls import patterns, url
from oauth2_provider import views
from django.conf import settings
from .views import ApiEndpoint
urlpatterns = patterns(
'',
url(r'^admin/', include(admin.site.urls)),
url(r'^o/', include('oauth2_provider.urls', namespace='oauth2_provider')), # look ma, I'm a provider!
url(r'^api/hello', ApiEndpoint.as_view()), # and also a resource server!
# OAuth2 provider endpoints
url(r'^o/authorize/$', views.AuthorizationView.as_view(), name="authorize"),
url(r'^o/token/$', views.TokenView.as_view(), name="token"),
url(r'^o/revoke-token/$', views.RevokeTokenView.as_view(), name="revoke-token"),
url(r'^api/hello', ApiEndpoint.as_view()), # a resource endpoint
)
if settings.DEBUG:
# OAuth2 Application management views
urlpatterns += patterns(
'',
url(r'^o/applications/$', views.ApplicationList.as_view(), name="application-list"),
url(r'^o/applications/register/$', views.ApplicationRegistration.as_view(), name="application-register"),
url(r'^o/applications/(?P<pk>\d+)/$', views.ApplicationDetail.as_view(), name="application-detail"),
url(r'^o/applications/(?P<pk>\d+)/delete/$', views.ApplicationDelete.as_view(), name="application-delete"),
url(r'^o/applications/(?P<pk>\d+)/update/$', views.ApplicationUpdate.as_view(), name="application-update"),
)
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.

Since we inherit from `ProtectedResourceView`, we're done and our API is OAuth2 protected - for the sake of the lazy
programmer.

Expand All @@ -51,7 +73,7 @@ Testing your API
Time to make requests to your API.

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

0 comments on commit 67d24c7

Please sign in to comment.