From f33a0aa47b049994e41188e6101cf79c4a2d5d4b Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 13 Oct 2012 00:45:05 +0100 Subject: [PATCH] oauth awesomeness --- docs/user/quickstart.rst | 42 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index c251e04baf..b73f296185 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -372,10 +372,44 @@ Another popular form of web service protection is Digest Authentication:: OAuth Authentication -------------------- -Miguel Araujo's `requests-oauth `_ -project provides a simple interface for establishing OAuth connections. -Documentation and examples can be found on the requests-oauth -`git repository `_. +Requests features robust, built-in OAuth support! + +OAuth takes many forms, so let's take a look at a few + +:: + + import requests + from requests.auth import OAuth1 + + url = u'https://api.twitter.com/1/account/settings.json' + + client_key = u'...' + client_secret = u'...' + resource_owner_key = u'...' + resource_owner_secret = u'...' + + +Query signing:: + + queryoauth = OAuth1(client_key, client_secret, + resource_owner_key, resource_owner_secret, + signature_type='query') + r = requests.get(url, auth=queryoauth) + +Header signing:: + + headeroauth = OAuth1(client_key, client_secret, + resource_owner_key, resource_owner_secret, + signature_type='auth_header') + r = requests.get(url, auth=headeroauth) + +Body signing:: + + bodyoauth = OAuth1(client_key, client_secret, + resource_owner_key, resource_owner_secret, + signature_type='body') + + r = requests.post(url, auth=bodyoauth) Redirection and History