不记名 python 助手
项目描述
承载蟒蛇
承载 Python 客户端
安装
pip install bearer
用法
从仪表板获取您的 Bearer Secret Key和集成 ID并使用 Bearer 客户端,如下所示:
调用任何 API
from bearer import Bearer
bearer = Bearer('BEARER_SECRET_KEY') # find it on https://app.bearer.sh/keys
github = (
bearer
.integration('your integration id') # you'll find it on the Bearer dashboard https://app.bearer.sh
.auth('your auth id') # Create an auth id for your integration via the dashboard
)
print(github.get('/repositories').json())
我们在内部使用请求,并从请求方法(request、、、、、、、、
)返回来自该库的响应。getheadpostputpatchdelete
更高级的例子:
# With query parameters
print(github.get('/repositories', query={ 'since': 364 }).json())
# With body data
print(github.post('/user/repos', body={ 'name': 'Just setting up my Bearer.sh' }).json())
设置请求超时和其他 http 客户端设置
Bearer 客户端是在优秀的请求库之上编写的。Bearer 提供了合理的默认值,但您可以通过使用 requests.request 方法使用http_client_settings关键字参数接受的任何关键字参数来调整 http 客户端配置。默认情况下,承载客户端在 5 秒后超时。Bearer 允许将超时时间增加到最多 30 秒
from bearer import Bearer
bearer = Bearer('BEARER_SECRET_KEY', http_client_settings={"timeout": 10}) # increase the request timeout to 10 seconds globally
# you can specify client settings per integration as well
github = bearer.integration('github', http_client_settings={"timeout": 2}) # github api is super fast 2 seconds should be plenty
print(github.get('/user/repos'))
发展
# setup venv
$ python -m venv venv
# install dependencies
$ venv/bin/python setup.py develop
# start the console
$ venv/bin/python
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
Bearer-3.1.0.tar.gz
(7.7 kB
查看哈希)
内置分布
Bearer-3.1.0-py3-none-any.whl
(9.9 kB
查看哈希)
关
Bearer-3.1.0- py3 -none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 0f61b1d8bdde4bf4ffc506de37aff039778687543d2d9bf0813d5e72c50904ed |
|
| MD5 | 24a73ae3c2ad46648d783db1955854d2 |
|
| 布莱克2-256 | 04fa08b2f336a8c3824e6fecf61af5187cb347caaa0a45b9dd9dfd89b063b1e2 |