Skip to content

johnnywsd/python-misfit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-misfit

Build Status

Coverage Status

Requirements Status

Misfit API Python Client Implementation

Quick Start

Install with pip install misfit

[Create an app](https://build.misfit.com/apps) with "Application Domain" set to http://127.0.0.1:8080/. Now use the "App key" and "App secret" in the following command: :: misfit authorize --client_id=<app_key> --client_secret=<app_secret>

That will save the necessary credentials for making further API calls to a file called "misfit.cfg". These credentials should be kept private. You can use same the command-line client to access everything in the [Resource API](https://build.misfit.com/docs/resource). You can also access the same resources using the Python API: :: >>> from misfit import Misfit >>> misfit = Misfit(<client_id>, <client_secret>, <access_token>) >>> print(misfit.profile()) {u'gender': u'male', u'birthday': u'1981-07-18', u'userId': u'scrubbed', u'name': u'Brad Pitcher'}

Slow Start

After you have installed and created your misfit app you can authorize and use the API with your own web server rather than the built-in CherryPy server like so: :: >>> from misfit.auth import MisfitAuth >>> auth = MisfitAuth(<client_id>, <client_secret>, redirect_uri=<redirect_uri>) >>> auth_url = auth.authorize_url()

Now redirect the user to auth_url. When control returns to your web server at the endpoint specified in <redirect_uri>, you will receive code and state GET params you can pass to the fetch_token method, which will return access_token, which is needed for further API calls: :: >>> access_token = auth.fetch_token(<code>, <state>) >>> from misfit import Misfit >>> misfit = Misfit(<client_id>, <client_secret>, <access_token>) >>> print(misfit.profile()) {u'gender': u'male', u'birthday': u'1981-07-18', u'userId': u'scrubbed', u'name': u'Brad Pitcher'}

Requirements

  • Python 2.6+ < 3
  • slumber
  • docopt
  • cherryPy
  • requests-oauthlib

About

Misfit API Python Client Implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%