summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmer Katz <omer.drow@gmail.com>2015-07-01 12:41:24 +0300
committerOmer Katz <omer.drow@gmail.com>2015-07-01 12:41:24 +0300
commit281cbdb2523495121c4f3e2ffd55616f7f829a6a (patch)
tree0faf45b57bd55b4b3cbed62e3943fdc1c181c864
parent16cd3b255b2c86ec7da412357cad899c72d8dbf7 (diff)
parent226e783e20b09f0e9314d4ad2b9a36410e3be529 (diff)
downloadoauthlib-281cbdb2523495121c4f3e2ffd55616f7f829a6a.tar.gz
Merge pull request #349 from foxx/patch-2
more code indent issues
-rw-r--r--docs/oauth2/server.rst126
1 files changed, 63 insertions, 63 deletions
diff --git a/docs/oauth2/server.rst b/docs/oauth2/server.rst
index fca6c3c..87f7e7d 100644
--- a/docs/oauth2/server.rst
+++ b/docs/oauth2/server.rst
@@ -262,12 +262,12 @@ can be seen below.
class MyRequestValidator(RequestValidator):
- def validate_client_id(self, client_id, request):
- try:
- Client.objects.get(client_id=client_id)
- return True
- except Client.DoesNotExist:
- return False
+ def validate_client_id(self, client_id, request):
+ try:
+ Client.objects.get(client_id=client_id)
+ return True
+ except Client.DoesNotExist:
+ return False
The full API you will need to implement is available in the
:doc:`RequestValidator <validator>` section. You might not need to implement
@@ -327,63 +327,63 @@ The example using Django but should be transferable to any framework.
# Handles GET and POST requests to /authorize
class AuthorizationView(View):
- def __init__(self):
- # Using the server from previous section
- self._authorization_endpoint = server
-
- def get(self, request):
- # You need to define extract_params and make sure it does not
- # include file like objects waiting for input. In Django this
- # is request.META['wsgi.input'] and request.META['wsgi.errors']
- uri, http_method, body, headers = extract_params(request)
-
- try:
- scopes, credentials = self._authorization_endpoint.validate_authorization_request(
- uri, http_method, body, headers)
-
- # Not necessarily in session but they need to be
- # accessible in the POST view after form submit.
- request.session['oauth2_credentials'] = credentials
-
- # You probably want to render a template instead.
- response = HttpResponse()
- response.write('<h1> Authorize access to %s </h1>' % client_id)
- response.write('<form method="POST" action="/authorize">')
- for scope in scopes or []:
- response.write('<input type="checkbox" name="scopes" ' +
- 'value="%s"/> %s' % (scope, scope))
- response.write('<input type="submit" value="Authorize"/>')
- return response
-
- # Errors that should be shown to the user on the provider website
- except errors.FatalClientError as e:
- return response_from_error(e)
-
- # Errors embedded in the redirect URI back to the client
- except errors.OAuth2Error as e:
- return HttpResponseRedirect(e.in_uri(e.redirect_uri))
-
- @csrf_exempt
- def post(self, request):
- uri, http_method, body, headers = extract_params(request)
-
- # The scopes the user actually authorized, i.e. checkboxes
- # that were selected.
- scopes = request.POST.getlist(['scopes'])
-
- # Extra credentials we need in the validator
- credentials = {'user': request.user}
-
- # The previously stored (in authorization GET view) credentials
- credentials.update(request.session.get('oauth2_credentials', {}))
-
- try:
- headers, body, status = self._authorization_endpoint.create_authorization_response(
- uri, http_method, body, headers, scopes, credentials)
- return response_from_return(headers, body, status)
-
- except errors.FatalClientError as e:
- return response_from_error(e)
+ def __init__(self):
+ # Using the server from previous section
+ self._authorization_endpoint = server
+
+ def get(self, request):
+ # You need to define extract_params and make sure it does not
+ # include file like objects waiting for input. In Django this
+ # is request.META['wsgi.input'] and request.META['wsgi.errors']
+ uri, http_method, body, headers = extract_params(request)
+
+ try:
+ scopes, credentials = self._authorization_endpoint.validate_authorization_request(
+ uri, http_method, body, headers)
+
+ # Not necessarily in session but they need to be
+ # accessible in the POST view after form submit.
+ request.session['oauth2_credentials'] = credentials
+
+ # You probably want to render a template instead.
+ response = HttpResponse()
+ response.write('<h1> Authorize access to %s </h1>' % client_id)
+ response.write('<form method="POST" action="/authorize">')
+ for scope in scopes or []:
+ response.write('<input type="checkbox" name="scopes" ' +
+ 'value="%s"/> %s' % (scope, scope))
+ response.write('<input type="submit" value="Authorize"/>')
+ return response
+
+ # Errors that should be shown to the user on the provider website
+ except errors.FatalClientError as e:
+ return response_from_error(e)
+
+ # Errors embedded in the redirect URI back to the client
+ except errors.OAuth2Error as e:
+ return HttpResponseRedirect(e.in_uri(e.redirect_uri))
+
+ @csrf_exempt
+ def post(self, request):
+ uri, http_method, body, headers = extract_params(request)
+
+ # The scopes the user actually authorized, i.e. checkboxes
+ # that were selected.
+ scopes = request.POST.getlist(['scopes'])
+
+ # Extra credentials we need in the validator
+ credentials = {'user': request.user}
+
+ # The previously stored (in authorization GET view) credentials
+ credentials.update(request.session.get('oauth2_credentials', {}))
+
+ try:
+ headers, body, status = self._authorization_endpoint.create_authorization_response(
+ uri, http_method, body, headers, scopes, credentials)
+ return response_from_return(headers, body, status)
+
+ except errors.FatalClientError as e:
+ return response_from_error(e)
# Handles requests to /token
class TokenView(View):