Skip to content
This repository
Browse code

oauth awesomeness

  • Loading branch information...
commit f33a0aa47b049994e41188e6101cf79c4a2d5d4b 1 parent 490ed74
Kenneth Reitz authored October 13, 2012

Showing 1 changed file with 38 additions and 4 deletions. Show diff stats Hide diff stats

  1. 42  docs/user/quickstart.rst
42  docs/user/quickstart.rst
Source Rendered
@@ -372,10 +372,44 @@ Another popular form of web service protection is Digest Authentication::
372 372
 OAuth Authentication
373 373
 --------------------
374 374
 
375  
-Miguel Araujo's `requests-oauth <http://pypi.python.org/pypi/requests-oauth>`_
376  
-project provides a simple interface for establishing OAuth connections.
377  
-Documentation and examples can be found on the requests-oauth
378  
-`git repository <https://github.com/maraujop/requests-oauth>`_.
  375
+Requests features robust, built-in OAuth support!
  376
+
  377
+OAuth takes many forms, so let's take a look at a few
  378
+
  379
+::
  380
+
  381
+    import requests
  382
+    from requests.auth import OAuth1
  383
+
  384
+    url = u'https://api.twitter.com/1/account/settings.json'
  385
+
  386
+    client_key = u'...'
  387
+    client_secret = u'...'
  388
+    resource_owner_key = u'...'
  389
+    resource_owner_secret = u'...'
  390
+
  391
+
  392
+Query signing::
  393
+
  394
+    queryoauth = OAuth1(client_key, client_secret,
  395
+                        resource_owner_key, resource_owner_secret,
  396
+                        signature_type='query')
  397
+    r = requests.get(url, auth=queryoauth)
  398
+
  399
+Header signing::
  400
+
  401
+    headeroauth = OAuth1(client_key, client_secret,
  402
+                         resource_owner_key, resource_owner_secret,
  403
+                         signature_type='auth_header')
  404
+    r = requests.get(url, auth=headeroauth)
  405
+
  406
+Body signing::
  407
+
  408
+    bodyoauth = OAuth1(client_key, client_secret,
  409
+                       resource_owner_key, resource_owner_secret,
  410
+                       signature_type='body')
  411
+
  412
+    r = requests.post(url, auth=bodyoauth)
379 413
 
380 414
 
381 415
 Redirection and History

0 notes on commit f33a0aa

Please sign in to comment.
Something went wrong with that request. Please try again.