Skip to main content

Auth0 Python SDK

Project description

Latest version released on PyPi Build status of the v2 branch Test coverage

In this repository, you’ll find all the information about integrating Auth0 with Python.

Check out the examples that we have in here in our examples folder. Each of them has a README on how to run them and on how to use them.

What is Auth0?

Auth0 helps you to:

  • Add authentication with multiple authentication sources, either social like Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, amont others, or enterprise identity systems like Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider.

  • Add authentication through more traditional username/password databases.

  • Add support for linking different user accounts with the same user.

  • Support for generating signed Json Web Tokens to call your APIs and flow the user identity securely.

  • Analytics of how, when and where users are logging in.

  • Pull data from other sources and add it to the user profile, through JavaScript rules.

Create a free Auth0 Account

  1. Go to Auth0 and click Sign Up.

  2. Use Google, GitHub or Microsoft Account to login.

Installation

You can install the auth0 python SDK issuing the following command.

pip install auth0-python

Management SDK Usage

To use the management library you will need to instantiate an Auth0 object with a domain and a token.

from auth0.v2.management import Auth0

domain = 'myaccount.auth0.com'
token = '{A_JWT_TOKEN}' # You can generate one of these by using the
                        # token generator at: https://auth0.com/docs/api/v2

auth0 = Auth0('myuser.auth0.com', token)

The Auth0() object is now ready to take orders! Let’s see how we can use this to get all available connections. (this action requires the token to have the following scope: read:connections)

auth0.connections.all()

Which will yield a list of connections similar to this:

[
    {
        'enabled_clients': [u'rOsnWgtw23nje2QCDuDJNVpxlsCylSLE'],
        'id': u'con_ErZf9LpXQDE0cNBr',
        'name': u'Amazon-Connection',
        'options': {u'profile': True, u'scope': [u'profile']},
        'strategy': u'amazon'
    },
    {
        'enabled_clients': [u'rOsnWgtw23nje2QCDuDJNVpxlsCylSLE'],
        'id': u'con_i8qF5DPiZ3FdadwJ',
        'name': u'Username-Password-Authentication',
        'options': {u'brute_force_protection': True},
        'strategy': u'auth0'
    }
]

Modifying an existing connection is equally as easy. Let’s change the name of connection 'con_ErZf9LpXQDE0cNBr'. (The token will need scope: update:connections to make this one work)

auth0.connections.update('con_ErZf9LpXQDE0cNBr', {'name': 'MyNewName'})

That’s it! using the get method of the connections endpoint we can verify that the rename actually happened.

modified_connection = auth0.connections.get('con_ErZf9LpXQDE0cNBr')

Which returns something like this

{
    'enabled_clients': [u'rOsnWgtw23nje2QCDuDJNVpxlsCylSLE'],
    'id': u'con_ErZf9LpXQDE0cNBr',
    'name': u'MyNewName',
    'options': {u'profile': True, u'scope': [u'profile']},
    'strategy': u'amazon'
}

Success!

All endpoints follow a similar structure to the connections one, and try to follow as closely as possible the API documentation.

Authentication SDK Usage

The Authentication SDK is divided into components mimicking the structure of the API’s documentation. For example:

from auth0.v2.authentication import Social

social = Social('myaccount.auth0.com')

s.login(client_id='...', acces_token='...', connection='facebook')

Available Management Endpoints

  • Clients() ( Auth0().clients )

  • Connections() ( Auth0().connections )

  • DeviceCredentials() ( Auth0().device_credentials )

  • Rules() ( Auth0().rules )

  • Users() ( Auth0().users )

  • Blacklists() ( Auth0().blacklists )

  • Emails() ( Auth0().emails )

  • Jobs() ( Auth0().jobs )

  • Stats() ( Auth0().stats )

  • Tenants() ( Auth0().tenants )

Available Authentication Endpoints

  • Users ( authentication.Users )

  • Database ( authentication.Database )

  • Delegated ( authentication.Delegated )

  • Enterprise ( authentication.Enterprise )

  • Link ( authentication.Link )

  • Passwordless ( authentication.Passwordless )

  • Social ( authentication.Social )

Contribute

Please see CONTRIBUTING.rst.

Change Log

Please see CHANGELOG.rst.

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.

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

auth0-python-2.0.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

auth0-python-2.0.0.macosx-10.10-x86_64.tar.gz (31.1 kB view details)

Uploaded Source

File details

Details for the file auth0-python-2.0.0.tar.gz.

File metadata

  • Download URL: auth0-python-2.0.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for auth0-python-2.0.0.tar.gz
Algorithm Hash digest
SHA256 21a4f2e06fb6cc6e4d33a459b7a55e6543b376d6a3d5141f9943e1e862ff6f40
MD5 40ed295efd3a00a545b35a34fb20fcdd
BLAKE2b-256 a515039b3cc0ebb54b33d77e61e9c1567a2d00529c8c789cd539a7d4f42ccbe6

See more details on using hashes here.

File details

Details for the file auth0-python-2.0.0.macosx-10.10-x86_64.tar.gz.

File metadata

File hashes

Hashes for auth0-python-2.0.0.macosx-10.10-x86_64.tar.gz
Algorithm Hash digest
SHA256 e7fb854a3123985cc62b2de0b228ad98b9d32abe14565f969262f3136e859882
MD5 c743b0cede4e26405c2af0eba32b9210
BLAKE2b-256 af42e8c6889eb54316eb8edb2fca628f7f433fc2120aa394e376522b2e3ffd66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page