aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/oauth
diff options
context:
space:
mode:
authorBen Sturmfels <ben@sturm.com.au>2021-03-05 23:12:19 +1100
committerBen Sturmfels <ben@sturm.com.au>2021-03-05 23:12:19 +1100
commitdec47c7102cf0aa3a4debf002928db8e460c0d71 (patch)
tree47631fc15c7af172aa699506adf3d76d3a71976c /mediagoblin/oauth
parent5f3a782fef4855e10b7259624a14d8afb0f7be93 (diff)
downloadmediagoblin-dec47c7102cf0aa3a4debf002928db8e460c0d71.tar.lz
mediagoblin-dec47c7102cf0aa3a4debf002928db8e460c0d71.tar.xz
mediagoblin-dec47c7102cf0aa3a4debf002928db8e460c0d71.zip
Apply `pyupgrade --py3-plus` to remove Python 2 compatibility code.
Diffstat (limited to 'mediagoblin/oauth')
-rw-r--r--mediagoblin/oauth/oauth.py10
-rw-r--r--mediagoblin/oauth/views.py22
2 files changed, 16 insertions, 16 deletions
diff --git a/mediagoblin/oauth/oauth.py b/mediagoblin/oauth/oauth.py
index cdd8c842..64ada12b 100644
--- a/mediagoblin/oauth/oauth.py
+++ b/mediagoblin/oauth/oauth.py
@@ -27,7 +27,7 @@ class GMGRequestValidator(RequestValidator):
def __init__(self, data=None, *args, **kwargs):
self.POST = data
- super(GMGRequestValidator, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
def check_nonce(self, nonce):
"""
@@ -43,15 +43,15 @@ class GMGRequestValidator(RequestValidator):
def save_request_token(self, token, request):
""" Saves request token in db """
- client_id = self.POST[u"oauth_consumer_key"]
+ client_id = self.POST["oauth_consumer_key"]
request_token = RequestToken(
token=token["oauth_token"],
secret=token["oauth_token_secret"],
)
request_token.client = client_id
- if u"oauth_callback" in self.POST:
- request_token.callback = self.POST[u"oauth_callback"]
+ if "oauth_callback" in self.POST:
+ request_token.callback = self.POST["oauth_callback"]
request_token.save()
def save_verifier(self, token, verifier, request):
@@ -188,4 +188,4 @@ class GMGRequest(Request):
kwargs["body"] = kwargs.get("body", request.data)
kwargs["headers"] = kwargs.get("headers", dict(request.headers))
- super(GMGRequest, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
diff --git a/mediagoblin/oauth/views.py b/mediagoblin/oauth/views.py
index ef91eb91..97426f22 100644
--- a/mediagoblin/oauth/views.py
+++ b/mediagoblin/oauth/views.py
@@ -50,7 +50,7 @@ def client_register(request):
error = "Could not decode data."
return json_response({"error": error}, status=400)
- if data is "":
+ if data == "":
error = "Unknown Content-Type"
return json_response({"error": error}, status=400)
@@ -128,7 +128,7 @@ def client_register(request):
logo_uri = data.get("logo_uri", client.logo_url)
if logo_uri is not None and not validate_url(logo_uri):
- error = "Logo URI {0} is not a valid URI.".format(logo_uri)
+ error = "Logo URI {} is not a valid URI.".format(logo_uri)
return json_response(
{"error": error},
status=400
@@ -140,7 +140,7 @@ def client_register(request):
contacts = data.get("contacts", None)
if contacts is not None:
- if not isinstance(contacts, six.text_type):
+ if not isinstance(contacts, str):
error = "Contacts must be a string of space-seporated email addresses."
return json_response({"error": error}, status=400)
@@ -148,7 +148,7 @@ def client_register(request):
for contact in contacts:
if not validate_email(contact):
# not a valid email
- error = "Email {0} is not a valid email.".format(contact)
+ error = "Email {} is not a valid email.".format(contact)
return json_response({"error": error}, status=400)
@@ -156,7 +156,7 @@ def client_register(request):
redirect_uris = data.get("redirect_uris", None)
if redirect_uris is not None:
- if not isinstance(redirect_uris, six.text_type):
+ if not isinstance(redirect_uris, str):
error = "redirect_uris must be space-seporated URLs."
return json_response({"error": error}, status=400)
@@ -165,7 +165,7 @@ def client_register(request):
for uri in redirect_uris:
if not validate_url(uri):
# not a valid uri
- error = "URI {0} is not a valid URI".format(uri)
+ error = "URI {} is not a valid URI".format(uri)
return json_response({"error": error}, status=400)
client.redirect_uri = redirect_uris
@@ -198,12 +198,12 @@ def request_token(request):
authorization = decode_authorization_header(data)
- if authorization == dict() or u"oauth_consumer_key" not in authorization:
+ if authorization == dict() or "oauth_consumer_key" not in authorization:
error = "Missing required parameter."
return json_response({"error": error}, status=400)
# check the client_id
- client_id = authorization[u"oauth_consumer_key"]
+ client_id = authorization["oauth_consumer_key"]
client = Client.query.filter_by(id=client_id).first()
if client == None:
@@ -217,8 +217,8 @@ def request_token(request):
tokens = rv.create_request_token(request, authorization)
# store the nonce & timestamp before we return back
- nonce = authorization[u"oauth_nonce"]
- timestamp = authorization[u"oauth_timestamp"]
+ nonce = authorization["oauth_nonce"]
+ timestamp = authorization["oauth_timestamp"]
timestamp = datetime.datetime.fromtimestamp(float(timestamp))
nc = NonceTimestamp(nonce=nonce, timestamp=timestamp)
@@ -309,7 +309,7 @@ def authorize_finish(request):
)
# okay we need to redirect them then!
- querystring = "?oauth_token={0}&oauth_verifier={1}".format(
+ querystring = "?oauth_token={}&oauth_verifier={}".format(
oauth_request.token,
oauth_request.verifier
)