summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorIb Lundgren <ib.lundgren@gmail.com>2013-03-05 12:07:08 -0800
committerIb Lundgren <ib.lundgren@gmail.com>2013-03-05 12:07:08 -0800
commit040f08ab058ef350177582bca42605a18708907c (patch)
treedecde0142daf5c22625fadecb9c990dc94ffbc03 /docs
parent520865b6631d91c560a94ebabe476926ed9878e9 (diff)
parentb8fcf7c3a58f08439ef6b12414e062f6447aecab (diff)
downloadoauthlib-040f08ab058ef350177582bca42605a18708907c.tar.gz
Merge pull request #126 from grunskis/master
Fixed issue #125 (Read the docs not generating docs from source)
Diffstat (limited to 'docs')
-rw-r--r--docs/client.rst27
-rw-r--r--docs/conf.py2
-rw-r--r--docs/server.rst21
3 files changed, 27 insertions, 23 deletions
diff --git a/docs/client.rst b/docs/client.rst
index dafb6e3..e3a601a 100644
--- a/docs/client.rst
+++ b/docs/client.rst
@@ -84,29 +84,30 @@ OAuth 1: Using the Client
OAuth 1 commonly use the Authorization header to pass the OAuth signature and other OAuth parameters. This is the default setting in Client and need not be specified. However you may also use the request url query or the request body to pass the parameters. You can specify this location using the signature_type constructor parameter, as shown below::
- # Embed in Authorization header (recommended)
- client = oauthlib.oauth1.Client('client_key',
- signature_type=SIGNATURE_TYPE_AUTH_HEADER,
- )
+ >>> # Embed in Authorization header (recommended)
+ >>> client = oauthlib.oauth1.Client('client_key',
+ signature_type=SIGNATURE_TYPE_AUTH_HEADER,
+ )
>>> uri, headers, body = client.sign('http://example.com/path?query=hello')
>>> headers
{u'Authorization': u'OAuth oauth_nonce="107143098223781054691360095427", oauth_timestamp="1360095427", oauth_version="1.0", oauth_signature_method="HMAC-SHA1", oauth_consumer_key="client_key", oauth_signature="86gpxY1DUXSBRRyWnRNJekeWEzw%3D"'}
- # Embed in url query
- client = oauthlib.oauth1.Client('client_key',
- signature_type=SIGNATURE_TYPE_QUERY,
- )
+ >>> # Embed in url query
+ >>> client = oauthlib.oauth1.Client('client_key',
+ signature_type=SIGNATURE_TYPE_QUERY,
+ )
+
>>> uri, headers, body = client.sign('http://example.com/path?query=hello')
>>> uri
http://example.com/path?query=hello&oauth_nonce=97599600646423262881360095509&oauth_timestamp=1360095509&oauth_version=1.0&oauth_signature_method=HMAC-SHA1&oauth_consumer_key=client_key&oauth_signature=VQAib%2F4uRPwfVmCZkgSE3q2p7zU%3D
- # Embed in body
- client = oauthlib.oauth1.Client('client_key',
- signature_type=SIGNATURE_TYPE_BODY,
- )
+ >>> # Embed in body
+ >>> client = oauthlib.oauth1.Client('client_key',
+ signature_type=SIGNATURE_TYPE_BODY,
+ )
- # Please set content-type to application/x-www-form-urlencoded
+ >>> # Please set content-type to application/x-www-form-urlencoded
>>> headers = {'Authorization':oauthlib.oauth1.CONTENT_TYPE_FORM_URLENCODED}
>>> uri, headers, body = client.sign('http://example.com/path?query=hello',
headers=headers)
diff --git a/docs/conf.py b/docs/conf.py
index 8593399..941ccf4 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -16,7 +16,7 @@ import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.insert(0, os.path.abspath('.'))
+sys.path.insert(0, os.path.abspath('..'))
# -- General configuration -----------------------------------------------------
diff --git a/docs/server.rst b/docs/server.rst
index 536d0f6..9a166ff 100644
--- a/docs/server.rst
+++ b/docs/server.rst
@@ -33,15 +33,18 @@ Implementing an OAuth provider is simple with OAuthLib. It is done by inheriting
There are three types of verifications you will want to perform, all which could be altered through the use of a realm parameter if you choose to allow/require this. Note that if verify_request returns false a HTTP 401Unauthorized should be returned. If a ValueError is raised a HTTP 400 Bad Request response should be returned. All request verifications will look similar to the following::
- try:
- authorized = server.verify_request(uri, http_method, body, headers)
- if not authorized:
- # return a HTTP 401 Unauthorized response
- else:
- # Create, save and return request token/access token/protected resource
- # or whatever you had in mind that required OAuth
- except ValueError:
- # return a HTTP 400 Bad Request response
+ try:
+ authorized = server.verify_request(uri, http_method, body, headers)
+ if not authorized:
+ # return a HTTP 401 Unauthorized response
+ pass
+ else:
+ # Create, save and return request token/access token/protected resource
+ # or whatever you had in mind that required OAuth
+ pass
+ except ValueError:
+ # return a HTTP 400 Bad Request response
+ pass
The only change will be parameters to the verify_request method.