This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

oauth2py

a simple, lightweight oauth client

require

python 2.7

supported

  • [x] Weibo
  • [x] QQ
  • [x] Facebook
  • [x] Github
  • [x] Twitter
  • [ ] Other…

useage

  1. create client

    • put oauth2py.json in your app root folder
    [{
        "name": "github",
        "client_id": "",
        "client_secret": "",
        "redirect_uri": "",
        "scope": ""
    },
    {
        "name": "twitter",
        "client_id": "",
        "client_secret": "",
        "redirect_uri": "",
        "scope": ""
    }]
    
    from oauth2py.client import OauthClient as oauth
    
    github = oauth.load('github')
    
    • or set config in code
    github.init({
        'client_id': '',
        'client_secret': '',
        'redirect_uri': '',
        'scope': ''
    })
    
  2. oauth

    1. get login url
    url = github.get_login_url(state='abc')
    
    1. get user info
    user = github.get_user_info('code=12345&state=abc')
    # or
    user = github.get_user_info({'code': '12345', 'state': 'abc'})
    
    1. save access token
    token = github.get_access_token()
    # save token ...
    
  3. access resource

    • get github repo list
    github.set_access_token({
        'access_token': '...'
    })
    github.access_resource(
            'GET', 'https://api.github.com/user/repos')
    
    • another example: post status to twitter
    twitter.set_access_token({
            'access_token': '...',
            'access_token_secret': '...'
        }
    )
    twitter.access_resource(
        'POST',
        url='https://api.twitter.com/1.1/statuses/update.json',
        data={
            'status': 'test from oauth2py!'
        }
    )
    

implement new providers

  • inherit oauth2py.Oauth2 or oauth2py.Oauth and set oauth urls

    class Github(Oauth2):
    
        NAME = 'Github'
        AUTHORIZATION_URL = 'https://github.com/login/oauth/authorize'
        ACCESS_TOKEN_URL = 'https://github.com/login/oauth/access_token'
        GET_USERINFO_URL = 'https://api.github.com/user'
    
        def __init__(self):
            super(Github, self).__init__()
    
  • parse user info from response

    def parse_user_info(self, response):
        return {
            'uid': str(response.get('id')),
            'name': response.get('name'),
            'avatar': response.get('avatar_url'),
            'raw': response
        }
    
Release History

Release History

1.1.4

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
oauth2py-1.1.4.tar.gz (5.5 kB) Copy SHA256 Checksum SHA256 Source May 24, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting