11
11
from django_sample import settings
12
12
from oauth2client .contrib import xsrfutil
13
13
from oauth2client .client import flow_from_clientsecrets
14
- from oauth2client .contrib .django_orm import Storage
14
+ from oauth2client .contrib .django_util . storage import DjangoORMStorage
15
15
16
16
# CLIENT_SECRETS, name of a file containing the OAuth 2.0 information for this
17
17
# application, including client_id and client_secret, which are found
27
27
28
28
@login_required
29
29
def index (request ):
30
- storage = Storage (CredentialsModel , 'id' , request .user , 'credential' )
30
+ storage = DjangoORMStorage (CredentialsModel , 'id' , request .user , 'credential' )
31
31
credential = storage .get ()
32
32
if credential is None or credential .invalid == True :
33
33
FLOW .params ['state' ] = xsrfutil .generate_token (settings .SECRET_KEY ,
@@ -50,10 +50,10 @@ def index(request):
50
50
51
51
@login_required
52
52
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' ]) ,
54
54
request .user ):
55
55
return HttpResponseBadRequest ()
56
56
credential = FLOW .step2_exchange (request .REQUEST )
57
- storage = Storage (CredentialsModel , 'id' , request .user , 'credential' )
57
+ storage = DjangoORMStorage (CredentialsModel , 'id' , request .user , 'credential' )
58
58
storage .put (credential )
59
59
return HttpResponseRedirect ("/" )
0 commit comments