用于aiohttp的oauth客户端
aio-alf的Python项目详细描述
aio alf构建状态
==
aiohttp oauth 2客户机
----
`aio alf`是基于aiohttp的asynchttp客户机的oauth 2客户机
功能
--
*自动令牌检索和更新
*令牌过期控制
*自动重试状态401(未经授权)
使用
----
初始化客户端并将其用作asynchttpclient对象。
…代码块::python
from aioalf.client import client
from aioalf.httpclient import httprequest
client=client(
token\'http://example.com/token',
client\'client-id',
客户机“secret=”secret“)
resource\uri='http://example.com/resource'
response=await client.request(
'post',
resource\uri,
data='{“name”:“alf”},
headers={“content-type”:“application/json”}
给取货客户端
…代码块::python
对“tokenstorage”对象和端口范围调用“use_implicit_flow”,它默认为范围(320032009)。
代码块::python
await use_implicit_flow(tokenstorage(),(30000,30009))
'http://example.com/resource')
text=await response.text()
print(response.status)
库中有一个非常简单的内存内令牌存储,如果需要将令牌保存更长时间,则应该对其方法进行子类化和覆盖。
——
发出请求时带有“不记名授权
标题<;http://tools.ietf.org/html/draft-ietf-oauth-v2-31”第7.1节>;` ` ` `:
…代码块:
get/resource/1http/1.1
host:example.com
authorization:bearer token
这种情况只发生一次,如果它再次失败,则返回错误响应。
故障排除
----
如果检索令牌时出错,则返回错误响应,
不会发生真正的请求。
发送至
`alf<;https://github.com/globocom/alf>;`
……|构建状态图像::https://secure.travis-ci.org/globocom/aio-alf.png?branch=master
:目标:https://travis ci.org/globocom/aio alf
==
aiohttp oauth 2客户机
----
`aio alf`是基于aiohttp的asynchttp客户机的oauth 2客户机
功能
--
*自动令牌检索和更新
*令牌过期控制
*自动重试状态401(未经授权)
使用
----
初始化客户端并将其用作asynchttpclient对象。
…代码块::python
from aioalf.client import client
from aioalf.httpclient import httprequest
client=client(
token\'http://example.com/token',
client\'client-id',
客户机“secret=”secret“)
resource\uri='http://example.com/resource'
response=await client.request(
'post',
resource\uri,
data='{“name”:“alf”},
headers={“content-type”:“application/json”}
给取货客户端
…代码块::python
对“tokenstorage”对象和端口范围调用“use_implicit_flow”,它默认为范围(320032009)。
代码块::python
await use_implicit_flow(tokenstorage(),(30000,30009))
'http://example.com/resource')
text=await response.text()
print(response.status)
库中有一个非常简单的内存内令牌存储,如果需要将令牌保存更长时间,则应该对其方法进行子类化和覆盖。
——
发出请求时带有“不记名授权
标题<;http://tools.ietf.org/html/draft-ietf-oauth-v2-31”第7.1节>;` ` ` `:
…代码块:
get/resource/1http/1.1
host:example.com
authorization:bearer token
这种情况只发生一次,如果它再次失败,则返回错误响应。
故障排除
----
如果检索令牌时出错,则返回错误响应,
不会发生真正的请求。
发送至
`alf<;https://github.com/globocom/alf>;`
……|构建状态图像::https://secure.travis-ci.org/globocom/aio-alf.png?branch=master
:目标:https://travis ci.org/globocom/aio alf