cooncesean / mixpanel-query-py

The Python interface to fetch data from Mixpanel.
MIT License
29 stars 17 forks source link

Improve authentication method support #30

Closed thesmallestduck closed 7 years ago

thesmallestduck commented 7 years ago

why

Mixpanel documentation clearly states signature-based authentication is considered deprecated. However, on several occasions we have been informed there are no plans to discontinue support of signature-based authentication. There has been some interest in supporting the new "secret in header" means of authentication. Two PRs have been submitted to that effect:

https://github.com/cooncesean/mixpanel-query-py/pull/27 https://github.com/cooncesean/mixpanel-query-py/pull/29

In the interest of keeping this repo up to date, we should strive to conform to the latest documentation from Mixpanel.

what

this PR:

new usage

If we merge this PR and update the pip version, you should not have to make any changes to your code in a production environment what-so-ever. The same signature method of authentication will be used, any unit tests you have setup to introspect url parameters should see everything behaving as usual.

However, if you wish to switch production code to use the secret-based means of authentication, you should be able to do so like this:

BEFORE:

from mixpanel_query.client import MixpanelQueryClient

signature_client = MixpanelQueryClient(API_KEY, API_SECRET)

AFTER:

rom mixpanel_query.client import MixpanelQueryClient
from mixpanel_query.auth import SecretAuth

secret_client = MixpanelQueryClient(API_KEY, API_SECRET, auth_class=SecretAuth)

notes

drathm commented 7 years ago

Great change! I've added JQL support to my local fork which requires the use of POST instead of the assumed GET in the connection class so I'll need to massage this a bit into my local branch.

I'm happy to submit another PR if desired. Here's my local branch with JQL https://github.com/Resly/mixpanel-query-py/tree/add-jql

thesmallestduck commented 7 years ago

@drathm it'd be great to support JQL, for sure. I'll take a look at your fork sometime this week. Otherwise PRs are always welcome.