This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

python-misfit

Misfit API Python Client Implementation

Requirements

  • Python >= 2.6, Python >= 3.3, or PyPy. You can download it from here
  • Pip. If you have Python >= 2.7.9 or >= 3.4 then you already have pip. Otherwise, please follow these instructions

Installing

Once you have satisfied the requirements listed above, install by running the following command from the terminal:

pip install misfit

Quick Start

Install with pip install misfit

Create an app 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. 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'}

Notifications

This library also includes some basic tools to ease notification handling. To use Misfit’s Notification API with your web application, the first thing you need to do is set up an endpoint to accept POST requests on the domain you specified when you created your app, like http://example.com/misfit/notification/ if your application domain is http://example.com.

Now, when you handle the request, just create a MisfitNotification object with the body of the request as an argument. The MisfitNotification constructor automatically verifies the signature of the SNS message so you can feel secure in the knowledge that the message is legitimate. It will raise cryptography.exceptions.InvalidSignature if the signature is not valid.

The MisfitNotification class handles both subscription confirmation messages and regular update messages. You can check the type of message by looking at the Type attribute, which will be either 'SubscriptionConfirmation' or 'Notification'. For a Notification message, you will find the updates as a list in a Message attribute. After you process the updates (which can take no longer than 15 seconds) make sure to respond with an HTTP status of 200, otherwise SNS may try to deliver it again. A full workflow should look something like this:

>>> from misfit.notification import MisfitNotification
>>> notification = MisfitNotification(content)
>>> if notification.Type == 'Notification':
>>>    for message in notification.Message:
>>>        if message.type == 'goals':
>>>            # Handle goal update
>>>        # Handle other message types
>>> # Give an empty response with a 200 status code

Once you have your endpoint up and running, go to your app and add your endpoint as a subscription hook URL, making sure the format is json. Click “Test Endpoint” and if all goes well, the verification should seamlessly take place. If not, please file an issue and we will try and help you debug. Now switch on all the resources you would like to receive and click “Update”. Soon you will be receiving Misfit notifications!

Release History

Release History

0.3.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
misfit-0.3.2.tar.gz (18.2 kB) Copy SHA256 Checksum SHA256 Source Nov 3, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting