Skip to content

Commit

Permalink
Merge pull request #2251 from GerardPaligot/fix_oauth2
Browse files Browse the repository at this point in the history
Change la librairie d'authentification pour django-oauth2-toolkit
  • Loading branch information
SpaceFox committed Feb 8, 2015
2 parents 14694e3 + a07a59e commit d8b2be3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ easy-thumbnails==2.2
# Api dependencies
djangorestframework==3.0.2
django-filter==0.8
django-oauth2-provider==0.2.6.1
django-oauth-toolkit==0.7.2
drf-extensions==0.2.6
django-rest-swagger==0.2.8
11 changes: 5 additions & 6 deletions zds/member/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.core import mail
from django.core.urlresolvers import reverse
from django.test.utils import override_settings
from provider.oauth2.models import AccessToken, Client
from oauth2_provider.models import Application, AccessToken
from rest_framework import status
from rest_framework.test import APITestCase
from rest_framework.test import APIClient
Expand Down Expand Up @@ -846,16 +846,15 @@ def test_remove_ban_at_a_member_without_permissions(self):


def create_oauth2_client(user):
client = Client.objects.create(user=user,
name='zds',
url='zestedesavoir.com',
client_type=1)
client = Application.objects.create(user=user,
client_type=Application.CLIENT_CONFIDENTIAL,
authorization_grant_type=Application.GRANT_PASSWORD)
client.save()
return client


def authenticate_client(client, clientAuth, username, password):
client.post('/oauth2/access_token', {
client.post('/oauth2/token/', {
'client_id': clientAuth.client_id,
'client_secret': clientAuth.client_secret,
'username': username,
Expand Down
5 changes: 2 additions & 3 deletions zds/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@
'social.apps.django_app.default',
'rest_framework',
'rest_framework_swagger',
'provider',
'provider.oauth2',
'oauth2_provider',

# Apps DB tables are created in THIS order by default
# --> Order is CRITICAL to properly handle foreign keys
Expand Down Expand Up @@ -217,7 +216,7 @@
'MAX_PAGINATE_BY': 100, # Maximum limit allowed when using `?page_size=xxx`.
# Active OAuth2 authentication.
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.OAuth2Authentication',
'oauth2_provider.ext.rest_framework.OAuth2Authentication',
),
'DEFAULT_PARSER_CLASSES': (
'rest_framework.parsers.JSONParser',
Expand Down
2 changes: 1 addition & 1 deletion zds/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def location(self, article):
# API
urlpatterns += patterns('',
url(r'^api/', include('rest_framework_swagger.urls')),
url(r'^oauth2/', include('provider.oauth2.urls', namespace='oauth2')),
url(r'^oauth2/', include('oauth2_provider.urls', namespace='oauth2_provider')),
url(r'^api/membres/', include('zds.member.api.urls')),
)

Expand Down

0 comments on commit d8b2be3

Please sign in to comment.