Skip to content
Myr

oauth awesomeness

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 490ed74 · Browse files · 1 file+38 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+38 added−4 removed

  • other:+38 added−4 removed

1 file+38 added−4 removed

modified:docs/user/quickstart.rst+38 added-4 removed
370 unmodified lines
371372OAuth Authentication373--------------------374375Miguel Araujo's `requests-oauth <http://pypi.python.org/pypi/requests-oauth>`_376project provides a simple interface for establishing OAuth connections.377Documentation and examples can be found on the requests-oauth378`git repository <https://github.com/maraujop/requests-oauth>`_.375Requests features robust, built-in OAuth support!376377OAuth takes many forms, so let's take a look at a few378379::380381 import requests382 from requests.auth import OAuth1383384 url = u'https://api.twitter.com/1/account/settings.json'385386 client_key = u'...'387 client_secret = u'...'388 resource_owner_key = u'...'389 resource_owner_secret = u'...'390391392Query signing::393394 queryoauth = OAuth1(client_key, client_secret,395 resource_owner_key, resource_owner_secret,396 signature_type='query')397 r = requests.get(url, auth=queryoauth)398399Header signing::400401 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)405406Body signing::407408 bodyoauth = OAuth1(client_key, client_secret,409 resource_owner_key, resource_owner_secret,410 signature_type='body')411412 r = requests.post(url, auth=bodyoauth)413414415Redirection and History416-----------------------417418Requests will automatically perform location redirection while using the GET
78 unmodified lines