X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/5913c54d19b8f6775633176032161d49f9b2f1aa..ca8dd597fad53663b91ed3f962d8c4f44cd8dfe9:/src/apiclient/views.py diff --git a/src/apiclient/views.py b/src/apiclient/views.py index 239682a5..652cad6b 100644 --- a/src/apiclient/views.py +++ b/src/apiclient/views.py @@ -1,7 +1,10 @@ +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# import cgi from django.contrib.auth.decorators import login_required -from django.core.urlresolvers import reverse +from django.urls import reverse from django.http import HttpResponseRedirect, HttpResponse import oauth2 @@ -22,7 +25,7 @@ def oauth(request, beta=False): raise Exception("Invalid response %s." % resp['status']) request_token = dict(cgi.parse_qsl(content)) - + conn = OAuthConnection.get(request.user, beta) # this might reset existing auth! conn.access = False @@ -31,10 +34,10 @@ def oauth(request, beta=False): conn.save() url = "%s?oauth_token=%s&oauth_callback=%s" % ( - WL_AUTHORIZE_URL if not beta else BETA_AUTHORIZE_URL, - request_token['oauth_token'], - request.build_absolute_uri(reverse("apiclient_oauth_callback" if not beta else "apiclient_beta_callback")), - ) + WL_AUTHORIZE_URL if not beta else BETA_AUTHORIZE_URL, + request_token['oauth_token'], + request.build_absolute_uri(reverse("apiclient_oauth_callback" if not beta else "apiclient_beta_callback")), + ) return HttpResponseRedirect(url) @@ -49,7 +52,7 @@ def oauth_callback(request, beta=False): token = oauth2.Token(conn.token, conn.token_secret) token.set_verifier(oauth_verifier) client = oauth2.Client(wl_consumer, token) - resp, content = client.request(WL_ACCESS_TOKEN_URL if not beta else BETA_ACCESS_TOKEN_URL, method="POST") + _resp, content = client.request(WL_ACCESS_TOKEN_URL if not beta else BETA_ACCESS_TOKEN_URL, method="POST") access_token = dict(cgi.parse_qsl(content)) conn.access = True