aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/oauth/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'mediagoblin/oauth/views.py')
-rw-r--r--mediagoblin/oauth/views.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/mediagoblin/oauth/views.py b/mediagoblin/oauth/views.py
index fd848467..ce12fbe0 100644
--- a/mediagoblin/oauth/views.py
+++ b/mediagoblin/oauth/views.py
@@ -18,6 +18,7 @@ import datetime
import six
+from oauthlib.oauth1.rfc5849.utils import UNICODE_ASCII_CHARACTER_SET
from oauthlib.oauth1 import (RequestTokenEndpoint, AuthorizationEndpoint,
AccessTokenEndpoint)
@@ -37,7 +38,7 @@ from mediagoblin.oauth.tools.forms import WTFormData
from mediagoblin.db.models import NonceTimestamp, Client, RequestToken
# possible client types
-client_types = ["web", "native"] # currently what pump supports
+CLIENT_TYPES = ["web", "native"] # currently what pump supports
@csrf_exempt
def client_register(request):
@@ -55,7 +56,7 @@ def client_register(request):
if "type" not in data:
error = "No registration type provided."
return json_response({"error": error}, status=400)
- if data.get("application_type", None) not in client_types:
+ if data.get("application_type", None) not in CLIENT_TYPES:
error = "Unknown application_type."
return json_response({"error": error}, status=400)
@@ -90,7 +91,7 @@ def client_register(request):
)
app_name = ("application_type", client.application_name)
- if app_name in client_types:
+ if app_name in CLIENT_TYPES:
client.application_name = app_name
elif client_type == "client_associate":
@@ -106,8 +107,8 @@ def client_register(request):
return json_response({"error": error}, status=400)
# generate the client_id and client_secret
- client_id = random_string(22) # seems to be what pump uses
- client_secret = random_string(43) # again, seems to be what pump uses
+ client_id = random_string(22, UNICODE_ASCII_CHARACTER_SET)
+ client_secret = random_string(43, UNICODE_ASCII_CHARACTER_SET)
expirey = 0 # for now, lets not have it expire
expirey_db = None if expirey == 0 else expirey
application_type = data["application_type"]
@@ -251,6 +252,7 @@ def authorize(request):
if oauth_request.verifier is None:
orequest = GMGRequest(request)
+ orequest.resource_owner_key = token
request_validator = GMGRequestValidator()
auth_endpoint = AuthorizationEndpoint(request_validator)
verifier = auth_endpoint.create_verifier(orequest, {})
@@ -332,10 +334,9 @@ def access_token(request):
error = "Missing required parameter."
return json_response({"error": error}, status=400)
-
+ request.resource_owner_key = parsed_tokens["oauth_consumer_key"]
request.oauth_token = parsed_tokens["oauth_token"]
request_validator = GMGRequestValidator(data)
av = AccessTokenEndpoint(request_validator)
tokens = av.create_access_token(request, {})
return form_response(tokens)
-