Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 34b5f2c

Browse files
author
Avinash
committed
upgrade to oauth2client 3.0.0 & django 1.10
1 parent 85d4d6a commit 34b5f2c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

samples/django_sample/plus/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from django.contrib.auth.models import User
33
from django.db import models
44

5-
from oauth2client.contrib.django_orm import CredentialsField
5+
from oauth2client.contrib.django_util.models import CredentialsField
66

77

88
class CredentialsModel(models.Model):

samples/django_sample/plus/views.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from django_sample import settings
1212
from oauth2client.contrib import xsrfutil
1313
from oauth2client.client import flow_from_clientsecrets
14-
from oauth2client.contrib.django_orm import Storage
14+
from oauth2client.contrib.django_util.storage import DjangoORMStorage
1515

1616
# CLIENT_SECRETS, name of a file containing the OAuth 2.0 information for this
1717
# application, including client_id and client_secret, which are found
@@ -27,7 +27,7 @@
2727

2828
@login_required
2929
def index(request):
30-
storage = Storage(CredentialsModel, 'id', request.user, 'credential')
30+
storage = DjangoORMStorage(CredentialsModel, 'id', request.user, 'credential')
3131
credential = storage.get()
3232
if credential is None or credential.invalid == True:
3333
FLOW.params['state'] = xsrfutil.generate_token(settings.SECRET_KEY,
@@ -50,10 +50,10 @@ def index(request):
5050

5151
@login_required
5252
def auth_return(request):
53-
if not xsrfutil.validate_token(settings.SECRET_KEY, request.REQUEST['state'],
53+
if not xsrfutil.validate_token(settings.SECRET_KEY, str(request.GET['state']),
5454
request.user):
5555
return HttpResponseBadRequest()
5656
credential = FLOW.step2_exchange(request.REQUEST)
57-
storage = Storage(CredentialsModel, 'id', request.user, 'credential')
57+
storage = DjangoORMStorage(CredentialsModel, 'id', request.user, 'credential')
5858
storage.put(credential)
5959
return HttpResponseRedirect("/")

0 commit comments

Comments
 (0)