Skip to main content

Python client for interacting with the Trace api.

Project description

Trace Python Client

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

Python client for interacting with the Trace api. For information on the API see the api documentation

Getting Started

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()

To use in a web app (using a very basic Flask example):

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())

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2018-07-22)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_trace-0.1.1.tar.gz (17.4 kB view hashes)

Uploaded source

Built Distribution

py_trace-0.1.1-py2.py3-none-any.whl (8.0 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page