没有项目描述

aioauth-client的Python项目详细描述


aiohttp oauth客户端–oauth对aiohttp/asyncio的支持。

Build Statushttp://img.shields.io/pypi/v/aioauth-client.svg?style=flat-squarehttp://img.shields.io/pypi/dm/aioauth-client.svg?style=flat-square

Requirements

  • python>;=3.5

Installation

aiohttp oauth client应该使用pip安装:

pip install aioauth-client

Usage

# OAuth1fromaioauth_clientimportTwitterClienttwitter=TwitterClient(consumer_key='J8MoJG4bQ9gcmGh8H7XhMg',consumer_secret='7WAscbSy65GmiVOvMU5EBYn5z80fhQkcFWSLMJJu4',)request_token,request_token_secret,_=yield fromtwitter.get_request_token()authorize_url=twitter.get_authorize_url(request_token)print("Open",authorize_url,"in a browser")# ...# Reload client to authorize_url and get oauth_verifier# ...print("PIN code:")oauth_verifier=input()oauth_token,oauth_token_secret,_=yield fromtwitter.get_access_token(oauth_verifier)# Save the tokens for later use# ...twitter=TwitterClient(consumer_key='J8MoJG4bQ9gcmGh8H7XhMg',consumer_secret='7WAscbSy65GmiVOvMU5EBYn5z80fhQkcFWSLMJJu4',oauth_token=oauth_token,oauth_token_secret=oauth_token_secret,)# Or you can use this if you have initilized client already# twitter.access_token = oauth_token# twitter.access_token_secret = oauth_token_secrettimeline=yield fromtwitter.request('GET','statuses/home_timeline.json')content=yield fromtimeline.read()print(content)
# OAuth2fromaioauth_clientimportGithubClientgithub=GithubClient(client_id='b6281b6fe88fa4c313e6',client_secret='21ff23d9f1cad775daee6a38d230e1ee05b04f7c',)authorize_url=github.get_authorize_url(scope="user:email")# ...# Reload client to authorize_url and get code# ...otoken,_=yield fromgithub.get_access_token(code)# Save the token for later use# ...github=GithubClient(client_id='b6281b6fe88fa4c313e6',client_secret='21ff23d9f1cad775daee6a38d230e1ee05b04f7c',access_token=otoken,)# Or you can use this if you have initilized client already# github.access_token = otokenresponse=yield fromgithub.request('GET','user')user_info=yield fromresponse.json()

Example

使用命令运行示例:

make run

在浏览器中打开http://localhost:5000

Bug tracker

如果您有任何建议、错误报告或 烦恼请向问题追踪者报告 在https://github.com/klen/aioauth-client/issues

Contributing

aiohttp oauth客户端的开发发生在:https://github.com/klen/aioauth-client

License

根据MIT license授权。

如果你想对这个角色表示感谢,欢迎你 明信片寄往:

Kirill Klenov
pos. Severny d. 8 kv. 3
MO, Istra, 143500
Russia

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
接收com。太阳媒体声音Java中来自MIDI控制器的FastShortMessage,如何解码?   JAVA日志记录:当日志文件将要滚动时,应用程序将暂停   java如何使用循环来重复函数选择   java OpenJPA和存储过程,Weblogic 12c   编码风格什么是正确的方式来使用。Java中的equals方法?   通过tcpsocket将xml从java发送到C#   java对象比JTable效率更高   java在运行时删除标志\半透明\状态   java将一个数均匀随机地分成m个部分   链表的Java数组   javajaxws:在数据库中记录请求和响应   java maven,执行标记,缺少id标记   泛型类中的java泛型转换