Skip to main content

Auth0 - Python

Latest version released on PyPi Build status Test coverage

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

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 Management API v2 token. Please note that these token last 24 hours, so if you need it constantly you should ask for it programatically using the client credentials grant with a non interactive client authorized to access the API. For example:

from auth0.v3.authentication import GetToken

domain = 'myaccount.auth0.com'
non_interactive_client_id = 'exampleid'
non_interactive_client_secret = 'examplesecret'

get_token = GetToken(domain)
token = get_token.client_credentials(non_interactive_client_id,
    non_interactive_client_secret, 'https://myaccount.auth0.com/api/v2/')
mgmt_api_token = token['access_token']

Then use the token you’ve obtained as follows:

from auth0.v3.management import Auth0

domain = 'myaccount.auth0.com'
mgmt_api_token = 'MGMT_API_TOKEN'

auth0 = Auth0(domain, mgmt_api_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.v3.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 )

  • ClientGrants() ( Auth0().client_grants )

  • Guardian() ( Auth0().guardian )

  • Logs() ( Auth0().logs )

  • ResourceServers() (Auth0().resource_servers )

  • UserBlocks() (Auth0().user_blocks )

Available Authentication Endpoints

  • Users ( authentication.Users )

  • Database ( authentication.Database )

  • Delegated ( authentication.Delegated )

  • Enterprise ( authentication.Enterprise )

  • Passwordless ( authentication.Passwordless )

  • Social ( authentication.Social )

  • API Authorization - Get Token ( authentication.GetToken)

  • API Authorization - Authorization Code Grant (authentication.AuthorizeClient)

Change Log

Please see CHANGELOG.md.

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.

Metadata

Release files for auth0-python 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for auth0-python 3.0.0
File Size Uploaded
auth0-python-3.0.0.tar.gz 20.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for auth0-python 3.0.0
File Interpreter ABI Platform
auth0-python-3.0.0.macosx-10.12-intel.tar.gz Details

Total release size: 62.8 kB

Release files / auth0-python-3.0.0.tar.gz

Download URL auth0-python-3.0.0.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b88a030cd9602623395bdd089c74d639465952fd078f03435995011eb49f9464
BLAKE2b-256 checksum
How to use checksums
1331f807152fd300b1642ba0520d7f029c4b12de3d98ad7d6a48018fb0818e2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / auth0-python-3.0.0.macosx-10.12-intel.tar.gz

Download URL auth0-python-3.0.0.macosx-10.12-intel.tar.gz
Size 42.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d710a5e1a96365d0d7b1b8101aec70246afd17f2c37979d0edc336f085e1106e
BLAKE2b-256 checksum
How to use checksums
359d16d28ad1488b1eb4c45c919f7f0b0bc268ad21ce8ef21e095b13560f33df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

6.7.0

2 release files

6.6.0

2 release files

6.5.0

2 release files

6.4.0

2 release files

6.3.0

2 release files

6.2.0

2 release files

6.1.0

2 release files

6.0.0

2 release files

5.8.0

2 release files

5.7.0

2 release files

5.6.0

2 release files

5.5.0

2 release files

5.4.0

2 release files

5.3.0

2 release files

5.2.0

2 release files

5.1.0

2 release files

5.0.0

2 release files

4.13.0

2 release files

4.12.0

2 release files

4.11.0

2 release files

4.10.0

2 release files

4.9.0

2 release files

4.8.1

2 release files

4.8.0

2 release files

4.7.2

2 release files

4.7.1

2 release files

4.7.0

2 release files

4.6.1

2 release files

4.6.0

2 release files

4.5.0

2 release files

4.4.2

2 release files

4.4.1

2 release files

4.4.0

2 release files

4.3.0

2 release files

4.2.0

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.24.1

2 release files

3.24.0

2 release files

3.23.1

2 release files

3.22.0

2 release files

3.20.0

2 release files

3.19.0

2 release files

3.18.0

2 release files

3.17.0

2 release files

3.16.2

2 release files

3.16.1

2 release files

3.15.0

2 release files

3.14.0

2 release files

3.13.0

2 release files

3.12.0

2 release files

3.11.0

2 release files

3.10.0

2 release files

3.9.2

2 release files

3.9.1

2 release files

3.9.0

2 release files

3.8.1

2 release files

3.8.0

2 release files

3.7.2

2 release files

3.7.1

2 release files

3.7.0

2 release files

3.6.1

2 release files

3.6.0

2 release files

3.5.0

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.2

2 release files

3.2.0

3 release files

3.1.4

2 release files

3.1.3

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

This release

3.0.0 This release

2 release files

2.0.1

2 release files

2.0.0

2 release files

2.0.0b1

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page