Skip to main content

An MAuth client based around the excellent requests library.

Project description


Build Status

requests-mauth is a python requests ( Authentication implementation for Medidata's MAuth authentication system.


To use MAuth authentication you will need:

  • An MAuth APP ID
  • An MAuth private key (with the public key registered with Medidata's MAuth server)


import requests
from requests_mauth import MAuth

# MAuth configuration
private_key = open("private.key", "r").read()
mauth = MAuth(APP_UUID, private_key)

# Call an MAuth protected resource, in this case an iMedidata API
# listing the studies for a particular user
user_uuid = "10ac3b0e-9fe2-11df-a531-12313900d531"
url = "" % user_uuid

# Make the requests call, passing the auth client
result = requests.get(url, auth=mauth)

# Print results
if result.status_code == 200:
    print([r["uuid"] for r in result.json()["studies"]])


We use travis for automated CI of the code (and status checks are required to pass prior to PR merges being accepted). We use travis to deploy updated versions to PyPI (only from master)

For local development (cross version) we use tox with pyenv to automate the running of unit tests against different python versions in virtualised python environments.

To setup your environment:

  1. Install Python
  2. Install Pyenv
    $ brew update
    $ brew install pyenv
  3. Install Pyenv versions for the Tox Suite
    $ pyenv install 2.7.16 3.3.6 3.4.6 3.5.3 3.6.1 3.7.2
  4. Install Tox
    $ pip install tox tox-pyenv
  5. Setup the local project versions (one for each env in the envlist)
     $ pyenv local 2.7.16 3.3.6 3.4.6 3.5.3 3.6.1 3.7.2
  6. Make any changes, update the tests and then run tests with tox
     Name                         Stmts   Miss  Cover
     requests_mauth/       3      0   100%
     requests_mauth/        31      0   100%
     requests_mauth/      34      0   100%
     TOTAL                           68      0   100%
     stats runtests: commands[1] | coverage html
     _________________________________________________________________________________________________________ summary __________________________________________________________________________________________________________
       clean: commands succeeded
       py27: commands succeeded
       py33: commands succeeded
       py34: commands succeeded
       py35: commands succeeded
       py36: commands succeeded
       stats: commands succeeded
       congratulations :)
  7. Coverage report can be viewed using open htmlcov/index.html
  8. Push your changes and create a PR to master
  9. Once the PR is complete, tag the branch and push it to github, this will trigger Travis to deploy to PyPI (make sure the version is consistent)
    $ git checkout master
    $ git pull
    $ git tag -a 1.0.2 -m "Requests MAuth 1.0.2"
    $ git push --tags

Download files

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

Files for requests-mauth, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size requests_mauth-1.1.0-py2.py3-none-any.whl (6.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size requests_mauth-1.1.0-py3.7.egg (9.8 kB) File type Egg Python version 3.7 Upload date Hashes View
Filename, size requests_mauth-1.1.0.tar.gz (6.3 kB) File type Source Python version None Upload date Hashes View

Supported by

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