Auth0

Overview

Auth0 is an authentication and authorization platform. This Parsons integration with the Auth0 Management API supports fetching and deleting user records.

Quickstart

To instantiate the Auth0 class, you can either store your Auth0 API client ID, client secret, and domain as environment variables (AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET, and AUTH0_DOMAIN, respectively) or pass in your client ID, client secret, and domain as arguments:

from parsons import Auth0

# First approach: Use API credentials via environmental variables
auth0 = Auth0()

# Second approach: Pass API credentials as arguments
auth0 = Shopify('auth0_client_id', 'auth0_client_secret', 'auth0_domain')

You can then call various endpoints:

# Fetch user by email
user = auth0.get_users_by_email('fakeemail@fakedomain.com')

API

class parsons.Auth0(client_id=None, client_secret=None, domain=None)[source]

Instantiate the Auth0 class

Args:
client_id: str

The Auth0 client ID. Not required if AUTH0_CLIENT_ID env variable set.

client_secret: str

The Auth0 client secret. Not required if AUTH0_CLIENT_SECRET env variable set.

domain: str

The Auth0 domain. Not required if AUTH0_DOMAIN env variable set.

Returns:

Auth0 Class

delete_user(id)[source]

Delete Auth0 user.

Args:
id: str

The user ID of the record to delete.

Returns:

int

get_users_by_email(email)[source]

Get Auth0 users by email.

Args:
email: str

The user email of the record to get.

Returns:

Table Class

upsert_user(email, username=None, given_name=None, family_name=None, app_metadata={}, user_metadata={}, connection='Username-Password-Authentication')[source]

Upsert Auth0 users by email.

Args:
email: str

The user email of the record to get.

username: optional str

Username to set for user

given_name: optional str

Given to set for user

family_name: optional str

Family name to set for user

app_metadata: optional dict

App metadata to set for user

user_metadata: optional dict

User metadata to set for user

Returns:

Requests Response object

block_user(user_id, connection='Username-Password-Authentication')[source]

Blocks Auth0 users by email - setting the “blocked” attribute on Auth0’s API.

Args:
user_id: str

Auth0 user id

connection: optional str

Name of auth0 connection (default to Username-Password-Authentication)

Returns:

Requests Response object

retrieve_all_users(connection='Username-Password-Authentication')[source]

Retrieves all Auth0 users using the batch jobs endpoint.

Args:
connection: optional str

Name of auth0 connection (default to Username-Password-Authentication)

Returns:

Requests Response object

get_connection_id(connection_name)[source]

Retrieves an Auth0 connection_id corresponding to a specific connection name

Args:
connection_name: str

Name of auth0 connection

Returns:

Connection ID string