跳转到主要内容

与Trace API交互的Python客户端。

项目描述

Trace Python客户端

https://img.shields.io/pypi/v/py-trace.svg https://img.shields.io/travis/aiguofer/py-trace.svg Documentation Status

用于与Trace API交互的Python客户端。有关API信息,请参阅API文档

入门指南

from py_trace import Trace

client = Trace(<client_key>, <client_secret>)
client.get_authorization_url()
# output should be like https://www.alpinereplay.com/api/oauth_login?oauth_token=<token>, go to the url and authorize the app
# after authorization, you should see a url like http://snow.traceup.com/api/oauth_login?oauth_token=<token>&oauth_verifier=<verifier>
client.get_access_token(<verifier>)
client.get_user()

在Web应用中使用(使用一个非常基本的Flask示例)

from flask import Flask, request, redirect
import json

app = Flask(__name__)
trace = Trace(<client_key>, <client_secret>, host + '/auth_callback')

@app.route('/auth_callback')
def handle_redirect():
    trace.get_access_token(request.args['oauth_verifier'])
    return redirect('/user')

@app.route('/auth')
def get_user_token():
    url = trace.get_auth_url()
    return redirect(url)

@app.route('/user')
def get_user():
    return json.dumps(trace.get_user())

鸣谢

此包是用Cookiecutteraudreyr/cookiecutter-pypackage项目模板创建的。

历史记录

0.1.0 (2018-07-22)

  • 首次发布在PyPI。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪一个,请了解更多关于安装软件包的信息。

源代码分发

py_trace-0.1.1.tar.gz (17.4 kB 查看散列值)

上传时间 源代码

构建分发

py_trace-0.1.1-py2.py3-none-any.whl (8.0 kB 查看散列值)

上传于 Python 2 Python 3

由...支持