GithubHelp home page GithubHelp logo

marktseng / requests-oauthlib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from requests/requests-oauthlib

0.0 2.0 0.0 1.41 MB

OAuthlib support for Python-Requests!

Home Page: https://requests-oauthlib.readthedocs.org/

License: ISC License

requests-oauthlib's Introduction

Requests-OAuthlib build-status coverage-status Documentation Status

This project provides first-class OAuth library support for Requests.

The OAuth 1 workflow

OAuth 1 can seem overly complicated and it sure has its quirks. Luckily, requests_oauthlib hides most of these and let you focus at the task at hand.

Accessing protected resources using requests_oauthlib is as simple as:

>>> from requests_oauthlib import OAuth1Session
>>> twitter = OAuth1Session('client_key',
                            client_secret='client_secret',
                            resource_owner_key='resource_owner_key',
                            resource_owner_secret='resource_owner_secret')
>>> url = 'https://api.twitter.com/1/account/settings.json'
>>> r = twitter.get(url)

Before accessing resources you will need to obtain a few credentials from your provider (i.e. Twitter) and authorization from the user for whom you wish to retrieve resources for. You can read all about this in the full OAuth 1 workflow guide on RTD.

The OAuth 2 workflow

OAuth 2 is generally simpler than OAuth 1 but comes in more flavours. The most common being the Authorization Code Grant, also known as the WebApplication flow.

Fetching a protected resource after obtaining an access token can be as simple as:

>>> from requests_oauthlib import OAuth2Session
>>> google = OAuth2Session(r'client_id', token=r'token')
>>> url = 'https://www.googleapis.com/oauth2/v1/userinfo'
>>> r = google.get(url)

Before accessing resources you will need to obtain a few credentials from your provider (i.e. Google) and authorization from the user for whom you wish to retrieve resources for. You can read all about this in the full OAuth 2 workflow guide on RTD.

Installation

To install requests and requests_oauthlib you can use pip:

$ pip install requests requests_oauthlib

requests-oauthlib's People

Contributors

akshar-raaj avatar al-the-x avatar alanjds avatar cam-stitt avatar cllu avatar dasevilla avatar filosottile avatar ft-arnout avatar ib-lundgren avatar jellonek avatar kevgathuku avatar lukasa avatar mart-e avatar matthewlmcclure avatar maxint avatar mouhtasi avatar nicksloan avatar pib avatar proppy avatar ralphbean avatar rintaun avatar rr2do2 avatar rvoicilas avatar shazow avatar singingwolfboy avatar stephane avatar synasius avatar thedrow avatar vinodc avatar xnox avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.