Giter Site home page Giter Site logo

social-oauth's Introduction

socialoauth

Python Package For SNS sites with OAuth2 support

socialoauth 专注于**大陆开放了OAuth2认证的网站

Feature

  • 易于扩展 参见doc.md

  • 统一的接口

    • 各个站点,都有 uid, name, avatar, 属性
    • 各个站点,都有统一的 api_http_getapi_http_post 接口
  • 统一的错误处理

    api_http_getapi_http_post 都可能引发异常,

    应用程序只要 try ... except SocialAPIError as e 就能得到一致的错误信息:

    • e.site_name 哪个站点发生错误
    • e.url 发生错误是请求的url
    • e.api_error_msg 由站点返回的错误信息 or urllib2 的错误信息

Supported sites

  • 人人
  • 腾讯
  • 豆瓣
  • 新浪微博
  • 网易微博
  • 搜狐微博
  • 百度
  • 开心网

Install

pip install socialoauth

# or

git clone https://github.com/yueyoum/social-oauth.git
cd social-oauth
python setup.py install

Example

快速体验 socialoauth

git clone https://github.com/yueyoum/social-oauth.git
cd social-oauth/example
cp settings.py.example settings.py

# 在这里按照你的情况修改settings.py

python index.py

如何配置 settings.py ? 参见doc.md

现在用浏览器打开对应的地址,就能体验相应的功能。

下面是我用 人人网 帐号登录的过程:

初始情况,首页只有一个 login 链接

step1

点击后,根据settings.py中的设置,显示可用的认证网站

step2

我用人人网帐号进行测试,点击后,转到人人登录认证的界面

step3

认证完毕后,就会显示用户的名字和小头像。

example中有个简单的session机制, 此时再打开首页(不关闭浏览器)就不用再登录,会直接显示名字和头像

step4

Document

参见doc.md

吐槽

  • 新浪微博,腾讯, 开心网的文档是最好的。

  • 人人网文档虽然内容丰富,但层次略混乱

  • 豆瓣文档太简陋

  • 搜狐文档就是个渣!!! 都不想添加搜狐支持了

  • 发现一些文档和实际操作有出入, 主要是文档里说的必要参数,不传也一样工作

    • 腾讯 文档里说取code的时候,state 必须 参数,但发现不传一样
    • 搜狐 和上面一样, wrap_client_state 参数

social-oauth's People

Contributors

yueyoum avatar andelf avatar summivox avatar

Watchers

James Cloos avatar Maxiee 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.