You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

auth0-python

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth0-python - pypi Package Compare versions

Comparing version
4.0.0
to
4.1.0
+1
-10
auth0_python.egg-info/PKG-INFO
Metadata-Version: 2.1
Name: auth0-python
Version: 4.0.0
Version: 4.1.0
Summary: Auth0 Python SDK

@@ -55,12 +55,3 @@ Home-page: https://github.com/auth0/auth0-python

[API documentation](https://auth0.com/docs/auth-api).
For example:
```python
from auth0.authentication import Social
social = Social('my-domain.us.auth0.com', 'my-client-id')
social.login(access_token='...', connection='facebook')
```
If you need to sign up a user using their email and password, you can use the Database object.

@@ -67,0 +58,0 @@

@@ -6,3 +6,2 @@ requests>=2.14.0

coverage
mock>=1.3.0
pre-commit
+1
-1

@@ -1,2 +0,2 @@

__version__ = "4.0.0"
__version__ = "4.1.0"

@@ -3,0 +3,0 @@ from auth0.exceptions import Auth0Error, RateLimitError, TokenValidationError

@@ -34,6 +34,6 @@ import aiohttp

# Wrap the auth client
super(AsyncClient, self).__init__(domain, telemetry, timeout, protocol)
super().__init__(domain, telemetry, timeout, protocol)
else:
# Wrap the mngtmt client
super(AsyncClient, self).__init__(
super().__init__(
domain, token, telemetry, timeout, protocol, rest_options

@@ -57,6 +57,6 @@ )

# Wrap the auth client
super(Wrapper, self).__init__(domain, telemetry, timeout, protocol)
super().__init__(domain, telemetry, timeout, protocol)
else:
# Wrap the mngtmt client
super(Wrapper, self).__init__(
super().__init__(
domain, token, telemetry, timeout, protocol, rest_options

@@ -71,3 +71,3 @@ )

self,
"{}_async".format(method),
f"{method}_async",
_gen_async(self._async_client, method),

@@ -74,0 +74,0 @@ )

@@ -16,3 +16,3 @@ """Token Verifier module"""

def __init__(self, jwks_url, algorithm="RS256"):
super(AsyncAsymmetricSignatureVerifier, self).__init__(jwks_url, algorithm)
super().__init__(jwks_url, algorithm)
self._fetcher = AsyncJwksFetcher(jwks_url)

@@ -62,3 +62,3 @@

def __init__(self, *args, **kwargs):
super(AsyncJwksFetcher, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self._async_client = AsyncRestClient(None)

@@ -116,5 +116,3 @@

return keys[key_id]
raise TokenValidationError(
'RSA Public Key with ID "{}" was not found.'.format(key_id)
)
raise TokenValidationError(f'RSA Public Key with ID "{key_id}" was not found.')

@@ -121,0 +119,0 @@

@@ -8,3 +8,3 @@ from auth0.rest import RestClient, RestClientOptions

class AuthenticationBase(object):
class AuthenticationBase:
"""Base authentication object providing simple REST methods.

@@ -11,0 +11,0 @@

@@ -27,3 +27,3 @@ import datetime

"sub": client_id,
"aud": "https://{}/".format(domain),
"aud": f"https://{domain}/",
"iat": now,

@@ -30,0 +30,0 @@ "exp": now + datetime.timedelta(seconds=180),

@@ -75,3 +75,3 @@ import warnings

return self.post(
"{}://{}/dbconnections/signup".format(self.protocol, self.domain), data=body
f"{self.protocol}://{self.domain}/dbconnections/signup", data=body
)

@@ -93,4 +93,4 @@

return self.post(
"{}://{}/dbconnections/change_password".format(self.protocol, self.domain),
f"{self.protocol}://{self.domain}/dbconnections/change_password",
data=body,
)

@@ -20,3 +20,2 @@ from .base import AuthenticationBase

):
"""Obtain a delegation token."""

@@ -42,4 +41,2 @@

return self.post(
"{}://{}/delegation".format(self.protocol, self.domain), data=data
)
return self.post(f"{self.protocol}://{self.domain}/delegation", data=data)

@@ -39,3 +39,3 @@ from .base import AuthenticationBase

return self.authenticated_post(
"{}://{}/oauth/token".format(self.protocol, self.domain),
f"{self.protocol}://{self.domain}/oauth/token",
data={

@@ -78,3 +78,3 @@ "client_id": self.client_id,

return self.post(
"{}://{}/oauth/token".format(self.protocol, self.domain),
f"{self.protocol}://{self.domain}/oauth/token",
data={

@@ -111,3 +111,3 @@ "client_id": self.client_id,

return self.authenticated_post(
"{}://{}/oauth/token".format(self.protocol, self.domain),
f"{self.protocol}://{self.domain}/oauth/token",
data={

@@ -160,3 +160,3 @@ "client_id": self.client_id,

return self.authenticated_post(
"{}://{}/oauth/token".format(self.protocol, self.domain),
f"{self.protocol}://{self.domain}/oauth/token",
data={

@@ -197,3 +197,3 @@ "client_id": self.client_id,

return self.authenticated_post(
"{}://{}/oauth/token".format(self.protocol, self.domain),
f"{self.protocol}://{self.domain}/oauth/token",
data={

@@ -231,3 +231,3 @@ "client_id": self.client_id,

return self.authenticated_post(
"{}://{}/oauth/token".format(self.protocol, self.domain),
f"{self.protocol}://{self.domain}/oauth/token",
data={

@@ -234,0 +234,0 @@ "client_id": self.client_id,

@@ -48,3 +48,3 @@ import warnings

return self.authenticated_post(
"{}://{}/passwordless/start".format(self.protocol, self.domain), data=data
f"{self.protocol}://{self.domain}/passwordless/start", data=data
)

@@ -72,3 +72,3 @@

return self.authenticated_post(
"{}://{}/passwordless/start".format(self.protocol, self.domain), data=data
f"{self.protocol}://{self.domain}/passwordless/start", data=data
)

@@ -29,3 +29,3 @@ from .base import AuthenticationBase

return self.authenticated_post(
"{}://{}/oauth/revoke".format(self.protocol, self.domain), data=body
f"{self.protocol}://{self.domain}/oauth/revoke", data=body
)

@@ -30,3 +30,3 @@ from .base import AuthenticationBase

return self.post(
"{}://{}/oauth/access_token".format(self.protocol, self.domain),
f"{self.protocol}://{self.domain}/oauth/access_token",
data={

@@ -33,0 +33,0 @@ "client_id": self.client_id,

@@ -11,3 +11,3 @@ """Token Verifier module"""

class SignatureVerifier(object):
class SignatureVerifier:
"""Abstract class that will verify a given JSON web token's signature

@@ -123,3 +123,3 @@ using the key fetched internally given its key id.

def __init__(self, shared_secret, algorithm="HS256"):
super(SymmetricSignatureVerifier, self).__init__(algorithm)
super().__init__(algorithm)
self._shared_secret = shared_secret

@@ -140,3 +140,3 @@

def __init__(self, jwks_url, algorithm="RS256"):
super(AsymmetricSignatureVerifier, self).__init__(algorithm)
super().__init__(algorithm)
self._fetcher = JwksFetcher(jwks_url)

@@ -148,3 +148,3 @@

class JwksFetcher(object):
class JwksFetcher:
"""Class that fetches and holds a JSON web key set.

@@ -243,5 +243,3 @@ This class makes use of an in-memory cache. For it to work properly, define this instance once and re-use it.

return keys[key_id]
raise TokenValidationError(
'RSA Public Key with ID "{}" was not found.'.format(key_id)
)
raise TokenValidationError(f'RSA Public Key with ID "{key_id}" was not found.')

@@ -248,0 +246,0 @@

from auth0.rest import RestClient, RestClientOptions
class Users(object):
class Users:
"""Users client.

@@ -35,3 +35,2 @@

def userinfo(self, access_token):
"""Returns the user information based on the Auth0 access token.

@@ -48,4 +47,4 @@ This endpoint will work only if openid was granted as a scope for the access_token.

return self.client.get(
url="{}://{}/userinfo".format(self.protocol, self.domain),
headers={"Authorization": "Bearer {}".format(access_token)},
url=f"{self.protocol}://{self.domain}/userinfo",
headers={"Authorization": f"Bearer {access_token}"},
)

@@ -9,3 +9,3 @@ class Auth0Error(Exception):

def __str__(self):
return "{}: {}".format(self.status_code, self.message)
return f"{self.status_code}: {self.message}"

@@ -15,5 +15,3 @@

def __init__(self, error_code, message, reset_at):
super(RateLimitError, self).__init__(
status_code=429, error_code=error_code, message=message
)
super().__init__(status_code=429, error_code=error_code, message=message)
self.reset_at = reset_at

@@ -20,0 +18,0 @@

from ..rest import RestClient
class Actions(object):
class Actions:
"""Auth0 Actions endpoints

@@ -42,6 +42,6 @@

def _url(self, *args):
url = "{}://{}/api/v2/actions".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/actions"
for p in args:
if p is not None:
url = "{}/{}".format(url, p)
url = f"{url}/{p}"
return url

@@ -48,0 +48,0 @@

@@ -7,3 +7,3 @@ import aiohttp

class AsyncAuth0(object):
class AsyncAuth0:
"""Provides easy access to all endpoint classes

@@ -10,0 +10,0 @@

from ..rest import RestClient
class AttackProtection(object):
class AttackProtection:
"""Auth0 attack protection endpoints

@@ -6,0 +6,0 @@

@@ -67,3 +67,3 @@ from ..utils import is_async_available

class Auth0(object):
class Auth0:
"""Provides easy access to all endpoint classes

@@ -70,0 +70,0 @@

from ..rest import RestClient
class Blacklists(object):
class Blacklists:
"""Auth0 blacklists endpoints

@@ -35,3 +35,3 @@

):
self.url = "{}://{}/api/v2/blacklists/tokens".format(protocol, domain)
self.url = f"{protocol}://{domain}/api/v2/blacklists/tokens"
self.client = RestClient(

@@ -38,0 +38,0 @@ jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options

from ..rest import RestClient
class Branding(object):
class Branding:
"""Auth0 Branding endpoints

@@ -42,6 +42,6 @@

def _url(self, *args):
url = "{}://{}/api/v2/branding".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/branding"
for p in args:
if p is not None:
url = "{}/{}".format(url, p)
url = f"{url}/{p}"
return url

@@ -97,1 +97,54 @@

)
def get_default_branding_theme(self):
"""Retrieve default branding theme.
See: https://auth0.com/docs/api/management/v2#!/Branding/get_default_branding_theme
"""
return self.client.get(self._url("themes", "default"))
def get_branding_theme(self, theme_id):
"""Retrieve branding theme.
Args:
theme_id (str): The theme_id to retrieve branding theme for.
See: https://auth0.com/docs/api/management/v2#!/Branding/get_branding_theme
"""
return self.client.get(self._url("themes", theme_id))
def delete_branding_theme(self, theme_id):
"""Delete branding theme.
Args:
theme_id (str): The theme_id to delete branding theme for.
See: https://auth0.com/docs/api/management/v2#!/Branding/delete_branding_theme
"""
return self.client.delete(self._url("themes", theme_id))
def update_branding_theme(self, theme_id, body):
"""Update branding theme.
Args:
theme_id (str): The theme_id to update branding theme for.
body (dict): The attributes to set on the theme.
See: https://auth0.com/docs/api/management/v2#!/Branding/patch_branding_theme
"""
return self.client.patch(self._url("themes", theme_id), data=body)
def create_branding_theme(self, body):
"""Create branding theme.
Args:
body (dict): The attributes to set on the theme.
See: https://auth0.com/docs/api/management/v2#!/Branding/post_branding_theme
"""
return self.client.post(self._url("themes"), data=body)
from ..rest import RestClient
class ClientCredentials(object):
class ClientCredentials:
"""Auth0 client credentials endpoints.

@@ -46,3 +46,3 @@

if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -49,0 +49,0 @@

from ..rest import RestClient
class ClientGrants(object):
class ClientGrants:
"""Auth0 client grants endpoints

@@ -42,5 +42,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/client-grants".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/client-grants"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -47,0 +47,0 @@

from ..rest import RestClient
class Clients(object):
class Clients:
"""Auth0 applications endpoints

@@ -42,5 +42,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/clients".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/clients"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -47,0 +47,0 @@

from ..rest import RestClient
class Connections(object):
class Connections:
"""Auth0 connection endpoints

@@ -42,5 +42,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/connections".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/connections"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -47,0 +47,0 @@

from ..rest import RestClient
class CustomDomains(object):
class CustomDomains:
"""Auth0 custom domains endpoints

@@ -42,3 +42,3 @@

def _url(self, id=None):
url = "{}://{}/api/v2/custom-domains".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/custom-domains"
if id is not None:

@@ -45,0 +45,0 @@ return url + "/" + id

from ..rest import RestClient
class DeviceCredentials(object):
class DeviceCredentials:
"""Auth0 connection endpoints

@@ -42,5 +42,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/device-credentials".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/device-credentials"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -47,0 +47,0 @@

from ..rest import RestClient
class EmailTemplates(object):
class EmailTemplates:
"""Auth0 email templates endpoints

@@ -42,5 +42,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/email-templates".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/email-templates"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -47,0 +47,0 @@

from ..rest import RestClient
class Emails(object):
class Emails:
"""Auth0 email endpoints

@@ -42,5 +42,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/emails/provider".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/emails/provider"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -47,0 +47,0 @@

from ..rest import RestClient
class Grants(object):
class Grants:
"""Auth0 grants endpoints

@@ -42,3 +42,3 @@

def _url(self, id=None):
url = "{}://{}/api/v2/grants".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/grants"
if id is not None:

@@ -45,0 +45,0 @@ return url + "/" + id

from ..rest import RestClient
class Guardian(object):
class Guardian:
"""Auth0 guardian endpoints

@@ -42,5 +42,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/guardian".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/guardian"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -68,3 +68,3 @@

"""
url = self._url("factors/{}".format(name))
url = self._url(f"factors/{name}")
return self.client.put(url, data=body)

@@ -105,3 +105,3 @@

"""
url = self._url("enrollments/{}".format(id))
url = self._url(f"enrollments/{id}")
return self.client.get(url)

@@ -119,3 +119,3 @@

"""
url = self._url("enrollments/{}".format(id))
url = self._url(f"enrollments/{id}")
return self.client.delete(url)

@@ -149,3 +149,3 @@

"""
url = self._url("factors/{}/providers/{}".format(factor_name, name))
url = self._url(f"factors/{factor_name}/providers/{name}")
return self.client.get(url)

@@ -167,3 +167,3 @@

"""
url = self._url("factors/{}/providers/{}".format(factor_name, name))
url = self._url(f"factors/{factor_name}/providers/{name}")
return self.client.put(url, data=body)
from ..rest import RestClient
class Hooks(object):
class Hooks:

@@ -43,5 +43,5 @@ """Hooks endpoint implementation.

def _url(self, id=None):
url = "{}://{}/api/v2/hooks".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/hooks"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -48,0 +48,0 @@

@@ -6,3 +6,3 @@ import warnings

class Jobs(object):
class Jobs:
"""Auth0 jobs endpoints

@@ -45,5 +45,5 @@

def _url(self, path=None):
url = "{}://{}/api/v2/jobs".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/jobs"
if path is not None:
return "{}/{}".format(url, path)
return f"{url}/{path}"
return url

@@ -69,3 +69,3 @@

"""
url = self._url("{}/errors".format(id))
url = self._url(f"{id}/errors")
return self.client.get(url)

@@ -72,0 +72,0 @@

from ..rest import RestClient
class LogStreams(object):
class LogStreams:
"""Auth0 log streams endpoints

@@ -42,5 +42,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/log-streams".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/log-streams"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -47,0 +47,0 @@

from ..rest import RestClient
class Logs(object):
class Logs:
"""Auth0 logs endpoints

@@ -42,5 +42,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/logs".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/logs"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -47,0 +47,0 @@

from ..rest import RestClient
class Organizations(object):
class Organizations:
"""Auth0 organizations endpoints

@@ -42,6 +42,6 @@

def _url(self, *args):
url = "{}://{}/api/v2/organizations".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/organizations"
for p in args:
if p is not None:
url = "{}/{}".format(url, p)
url = f"{url}/{p}"
return url

@@ -48,0 +48,0 @@

from ..rest import RestClient
class Prompts(object):
class Prompts:
"""Auth0 prompts endpoints

@@ -42,5 +42,5 @@

def _url(self, prompt=None, language=None):
url = "{}://{}/api/v2/prompts".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/prompts"
if prompt is not None and language is not None:
return "{}/{}/custom-text/{}".format(url, prompt, language)
return f"{url}/{prompt}/custom-text/{language}"
return url

@@ -47,0 +47,0 @@

from ..rest import RestClient
class ResourceServers(object):
class ResourceServers:
"""Auth0 resource servers endpoints

@@ -42,5 +42,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/resource-servers".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/resource-servers"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -47,0 +47,0 @@

from ..rest import RestClient
class Roles(object):
class Roles:
"""Auth0 roles endpoints

@@ -42,5 +42,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/roles".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/roles"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -151,3 +151,3 @@

url = self._url("{}/users".format(id))
url = self._url(f"{id}/users")
return self.client.get(url, params=params)

@@ -165,3 +165,3 @@

"""
url = self._url("{}/users".format(id))
url = self._url(f"{id}/users")
body = {"users": users}

@@ -192,3 +192,3 @@ return self.client.post(url, data=body)

}
url = self._url("{}/permissions".format(id))
url = self._url(f"{id}/permissions")
return self.client.get(url, params=params)

@@ -206,3 +206,3 @@

"""
url = self._url("{}/permissions".format(id))
url = self._url(f"{id}/permissions")
body = {"permissions": permissions}

@@ -221,4 +221,4 @@ return self.client.delete(url, data=body)

"""
url = self._url("{}/permissions".format(id))
url = self._url(f"{id}/permissions")
body = {"permissions": permissions}
return self.client.post(url, data=body)
from ..rest import RestClient
class RulesConfigs(object):
class RulesConfigs:
"""RulesConfig endpoint implementation.

@@ -42,3 +42,3 @@

def _url(self, id=None):
url = "{}://{}/api/v2/rules-configs".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/rules-configs"
if id is not None:

@@ -75,4 +75,4 @@ return url + "/" + id

"""
url = self._url("{}".format(key))
url = self._url(f"{key}")
body = {"value": value}
return self.client.put(url, data=body)
from ..rest import RestClient
class Rules(object):
class Rules:
"""Rules endpoint implementation.

@@ -42,5 +42,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/rules".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/rules"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -47,0 +47,0 @@

from ..rest import RestClient
class Stats(object):
class Stats:
"""Auth0 stats endpoints

@@ -42,3 +42,3 @@

def _url(self, action):
return "{}://{}/api/v2/stats/{}".format(self.protocol, self.domain, action)
return f"{self.protocol}://{self.domain}/api/v2/stats/{action}"

@@ -45,0 +45,0 @@ def active_users(self):

from ..rest import RestClient
class Tenants(object):
class Tenants:
"""Auth0 tenants endpoints

@@ -42,3 +42,3 @@

def _url(self):
return "{}://{}/api/v2/tenants/settings".format(self.protocol, self.domain)
return f"{self.protocol}://{self.domain}/api/v2/tenants/settings"

@@ -45,0 +45,0 @@ def get(self, fields=None, include_fields=True):

from ..rest import RestClient
class Tickets(object):
class Tickets:
"""Auth0 tickets endpoints

@@ -42,3 +42,3 @@

def _url(self, action):
return "{}://{}/api/v2/tickets/{}".format(self.protocol, self.domain, action)
return f"{self.protocol}://{self.domain}/api/v2/tickets/{action}"

@@ -45,0 +45,0 @@ def create_email_verification(self, body):

from ..rest import RestClient
class UserBlocks(object):
class UserBlocks:
"""Auth0 user blocks endpoints

@@ -42,5 +42,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/user-blocks".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/user-blocks"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -47,0 +47,0 @@

from ..rest import RestClient
class UsersByEmail(object):
class UsersByEmail:
"""Auth0 users by email endpoints

@@ -42,3 +42,3 @@

def _url(self):
return "{}://{}/api/v2/users-by-email".format(self.protocol, self.domain)
return f"{self.protocol}://{self.domain}/api/v2/users-by-email"

@@ -45,0 +45,0 @@ def search_users_by_email(self, email, fields=None, include_fields=True):

@@ -6,3 +6,3 @@ import warnings

class Users(object):
class Users:
"""Auth0 users endpoints

@@ -45,5 +45,5 @@

def _url(self, id=None):
url = "{}://{}/api/v2/users".format(self.protocol, self.domain)
url = f"{self.protocol}://{self.domain}/api/v2/users"
if id is not None:
return "{}/{}".format(url, id)
return f"{url}/{id}"
return url

@@ -188,3 +188,3 @@

url = self._url("{}/organizations".format(id))
url = self._url(f"{id}/organizations")
return self.client.get(url, params=params)

@@ -215,3 +215,3 @@

url = self._url("{}/roles".format(id))
url = self._url(f"{id}/roles")
return self.client.get(url, params=params)

@@ -229,3 +229,3 @@

"""
url = self._url("{}/roles".format(id))
url = self._url(f"{id}/roles")
body = {"roles": roles}

@@ -244,3 +244,3 @@ return self.client.delete(url, data=body)

"""
url = self._url("{}/roles".format(id))
url = self._url(f"{id}/roles")
body = {"roles": roles}

@@ -272,3 +272,3 @@ return self.client.post(url, data=body)

}
url = self._url("{}/permissions".format(id))
url = self._url(f"{id}/permissions")
return self.client.get(url, params=params)

@@ -286,3 +286,3 @@

"""
url = self._url("{}/permissions".format(id))
url = self._url(f"{id}/permissions")
body = {"permissions": permissions}

@@ -301,3 +301,3 @@ return self.client.delete(url, data=body)

"""
url = self._url("{}/permissions".format(id))
url = self._url(f"{id}/permissions")
body = {"permissions": permissions}

@@ -317,3 +317,3 @@ return self.client.post(url, data=body)

"""
url = self._url("{}/multifactor/{}".format(id, provider))
url = self._url(f"{id}/multifactor/{provider}")
return self.client.delete(url)

@@ -329,3 +329,3 @@

"""
url = self._url("{}/authenticators".format(id))
url = self._url(f"{id}/authenticators")
return self.client.delete(url)

@@ -345,3 +345,3 @@

"""
url = self._url("{}/identities/{}/{}".format(id, provider, user_id))
url = self._url(f"{id}/identities/{provider}/{user_id}")
return self.client.delete(url)

@@ -363,3 +363,3 @@

"""
url = self._url("{}/identities".format(user_id))
url = self._url(f"{user_id}/identities")
return self.client.post(url, data=body)

@@ -375,3 +375,3 @@

"""
url = self._url("{}/recovery-code-regeneration".format(user_id))
url = self._url(f"{user_id}/recovery-code-regeneration")
return self.client.post(url)

@@ -387,3 +387,3 @@

"""
url = self._url("{}/enrollments".format(user_id))
url = self._url(f"{user_id}/enrollments")
return self.client.get(url)

@@ -423,3 +423,3 @@

url = self._url("{}/logs".format(user_id))
url = self._url(f"{user_id}/logs")
return self.client.get(url, params=params)

@@ -436,5 +436,95 @@

url = self._url(
"{}/multifactor/actions/invalidate-remember-browser".format(user_id)
)
url = self._url(f"{user_id}/multifactor/actions/invalidate-remember-browser")
return self.client.post(url)
def get_authentication_methods(self, user_id):
"""Gets a list of authentication methods
Args:
user_id (str): The user_id to get a list of authentication methods for.
See: https://auth0.com/docs/api/management/v2#!/Users/get_authentication_methods
"""
url = self._url(f"{user_id}/authentication-methods")
return self.client.get(url)
def get_authentication_method_by_id(self, user_id, authentication_method_id):
"""Gets an authentication method by ID.
Args:
user_id (str): The user_id to get an authentication method by ID for.
authentication_method_id (str): The authentication_method_id to get an authentication method by ID for.
See: https://auth0.com/docs/api/management/v2#!/Users/get_authentication_methods_by_authentication_method_id
"""
url = self._url(f"{user_id}/authentication-methods/{authentication_method_id}")
return self.client.get(url)
def create_authentication_method(self, user_id, body):
"""Creates an authentication method for a given user.
Args:
user_id (str): The user_id to create an authentication method for a given user.
body (dict): the request body to create an authentication method for a given user.
See: https://auth0.com/docs/api/management/v2#!/Users/post_authentication_methods
"""
url = self._url(f"{user_id}/authentication-methods")
return self.client.post(url, data=body)
def update_authentication_methods(self, user_id, body):
"""Updates all authentication methods for a user by replacing them with the given ones.
Args:
user_id (str): The user_id to update all authentication methods for.
body (dict): the request body to update all authentication methods with.
See: https://auth0.com/docs/api/management/v2#!/Users/put_authentication_methods
"""
url = self._url(f"{user_id}/authentication-methods")
return self.client.put(url, data=body)
def update_authentication_method_by_id(
self, user_id, authentication_method_id, body
):
"""Updates an authentication method.
Args:
user_id (str): The user_id to update an authentication method.
authentication_method_id (str): The authentication_method_id to update an authentication method for.
body (dict): the request body to update an authentication method.
See: https://auth0.com/docs/api/management/v2#!/Users/patch_authentication_methods_by_authentication_method_id
"""
url = self._url(f"{user_id}/authentication-methods/{authentication_method_id}")
return self.client.patch(url, data=body)
def delete_authentication_methods(self, user_id):
"""Deletes all authentication methods for the given user.
Args:
user_id (str): The user_id to delete all authentication methods for the given user for.
See: https://auth0.com/docs/api/management/v2#!/Users/delete_authentication_methods
"""
url = self._url(f"{user_id}/authentication-methods")
return self.client.delete(url)
def delete_authentication_method_by_id(self, user_id, authentication_method_id):
"""Deletes an authentication method by ID.
Args:
user_id (str): The user_id to delete an authentication method by ID for.
authentication_method_id (str): The authentication_method_id to delete an authentication method by ID for.
See: https://auth0.com/docs/api/management/v2#!/Users/delete_authentication_methods_by_authentication_method_id
"""
url = self._url(f"{user_id}/authentication-methods/{authentication_method_id}")
return self.client.delete(url)

@@ -34,3 +34,3 @@ import asyncio

def __init__(self, *args, **kwargs):
super(AsyncRestClient, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self._session = None

@@ -132,3 +132,3 @@ sock_connect, sock_read = (

class RequestsResponse(object):
class RequestsResponse:
def __init__(self, response, text):

@@ -135,0 +135,0 @@ self.status_code = response.status

@@ -15,3 +15,3 @@ import base64

class RestClientOptions(object):
class RestClientOptions:
"""Configuration object for RestClient. Used for configuring

@@ -51,3 +51,3 @@ additional RestClient options, such as rate-limit

class RestClient(object):
class RestClient:
"""Provides simple methods for handling all RESTful api endpoints.

@@ -84,3 +84,3 @@

if jwt is not None:
self.base_headers["Authorization"] = "Bearer {}".format(self.jwt)
self.base_headers["Authorization"] = f"Bearer {self.jwt}"

@@ -103,3 +103,3 @@ if options.telemetry:

{
"User-Agent": "Python/{}".format(py_version),
"User-Agent": f"Python/{py_version}",
"Auth0-Client": base64.b64encode(auth0_client).decode(),

@@ -248,3 +248,3 @@ }

class Response(object):
class Response:
def __init__(self, status_code, content, headers):

@@ -294,5 +294,3 @@ self._status_code = status_code

content = json.loads(response.text)
super(JsonResponse, self).__init__(
response.status_code, content, response.headers
)
super().__init__(response.status_code, content, response.headers)

@@ -320,5 +318,3 @@ def _error_code(self):

def __init__(self, response):
super(PlainResponse, self).__init__(
response.status_code, response.text, response.headers
)
super().__init__(response.status_code, response.text, response.headers)

@@ -334,3 +330,3 @@ def _error_code(self):

def __init__(self, status_code):
super(EmptyResponse, self).__init__(status_code, "", {})
super().__init__(status_code, "", {})

@@ -337,0 +333,0 @@ def _error_code(self):

import re
import unittest
from unittest.mock import ANY, MagicMock
from aioresponses import CallbackResult, aioresponses
from callee import Attrs
from mock import ANY, MagicMock

@@ -8,0 +8,0 @@ from auth0.management.async_auth0 import AsyncAuth0 as Auth0

import time
import unittest
from unittest.mock import ANY

@@ -8,3 +9,2 @@ import jwt

from cryptography.hazmat.primitives import serialization
from mock import ANY

@@ -11,0 +11,0 @@ from .. import TokenValidationError

@@ -8,2 +8,3 @@ import base64

from tempfile import TemporaryFile
from unittest.mock import ANY, MagicMock

@@ -13,3 +14,2 @@ import aiohttp

from callee import Attrs
from mock import ANY, MagicMock

@@ -37,3 +37,3 @@ from auth0.asyncify import asyncify

headers = {
"User-Agent": "Python/{}".format(platform.python_version()),
"User-Agent": f"Python/{platform.python_version()}",
"Authorization": "Bearer jwt",

@@ -40,0 +40,0 @@ "Content-Type": "application/json",

@@ -5,4 +5,4 @@ import base64

import unittest
from unittest import mock
import mock
import requests

@@ -37,3 +37,3 @@

self.assertEqual(user_agent, "Python/{}".format(python_version))
self.assertEqual(user_agent, f"Python/{python_version}")
self.assertEqual(auth0_client, client_info)

@@ -40,0 +40,0 @@ self.assertEqual(content_type, "application/json")

import unittest
from unittest import mock
import mock
from ...authentication.database import Database

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...authentication.delegated import Delegated

@@ -11,3 +10,2 @@

def test_get_token_id_token(self, mock_post):
d = Delegated("my.domain.com", "cid")

@@ -40,3 +38,2 @@

def test_get_token_refresh_token(self, mock_post):
d = Delegated("my.domain.com", "cid")

@@ -68,3 +65,2 @@

def test_get_token_value_error(self, mock_post):
d = Delegated("my.domain.com", "cid")

@@ -71,0 +67,0 @@

import unittest
from unittest import mock
import mock
from ...authentication.enterprise import Enterprise

@@ -11,3 +10,2 @@

def test_saml_metadata(self, mock_get):
e = Enterprise("my.domain.com", "cid")

@@ -21,3 +19,2 @@

def test_wsfed_metadata(self, mock_get):
e = Enterprise("my.domain.com", "cid")

@@ -24,0 +21,0 @@

import unittest
from unittest import mock
import mock
from callee.strings import Glob

@@ -25,3 +25,2 @@ from cryptography.hazmat.primitives import asymmetric, serialization

def test_authorization_code(self, mock_post):
g = GetToken("my.domain.com", "cid", client_secret="clsec")

@@ -51,3 +50,2 @@

def test_authorization_code_with_client_assertion(self, mock_post):
g = GetToken(

@@ -76,3 +74,2 @@ "my.domain.com", "cid", client_assertion_signing_key=get_private_key()

def test_authorization_code_pkce(self, mock_post):
g = GetToken("my.domain.com", "cid")

@@ -103,3 +100,2 @@

def test_client_credentials(self, mock_post):
g = GetToken("my.domain.com", "cid", client_secret="clsec")

@@ -146,3 +142,2 @@

def test_login(self, mock_post):
g = GetToken("my.domain.com", "cid", client_secret="clsec")

@@ -202,3 +197,2 @@

def test_passwordless_login_with_sms(self, mock_post):
g = GetToken("my.domain.com", "cid", client_secret="csec")

@@ -205,0 +199,0 @@

import unittest
from unittest import mock
import mock
from ...authentication.passwordless import Passwordless

@@ -11,3 +10,2 @@

def test_send_email(self, mock_post):
p = Passwordless("my.domain.com", "cid")

@@ -32,3 +30,2 @@

def test_send_email_with_auth_params(self, mock_post):
p = Passwordless("my.domain.com", "cid")

@@ -54,3 +51,2 @@

def test_send_email_with_client_secret(self, mock_post):
p = Passwordless("my.domain.com", "cid", client_secret="csecret")

@@ -57,0 +53,0 @@

import unittest
from unittest import mock
import mock
from ...authentication.revoke_token import RevokeToken

@@ -11,3 +10,2 @@

def test_revoke_refresh_token(self, mock_post):
a = RevokeToken("my.domain.com", "cid")

@@ -14,0 +12,0 @@

import unittest
from unittest import mock
import mock
from ...authentication.social import Social

@@ -6,0 +5,0 @@

import json
import time
import unittest
from unittest.mock import MagicMock, patch
import jwt
from mock import MagicMock, patch

@@ -80,3 +80,2 @@ from ...authentication.token_verifier import (

def test_asymmetric_verifier_fetches_key(self):
mock_fetcher = JwksFetcher("some URL")

@@ -83,0 +82,0 @@ mock_fetcher.get_key = MagicMock("get_key")

import unittest
from unittest import mock
import mock
from ...authentication.users import Users

@@ -11,3 +10,2 @@

def test_userinfo(self, mock_get):
u = Users("my.domain.com")

@@ -14,0 +12,0 @@

import unittest
from unittest import mock
import mock
from ...management.actions import Actions

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.attack_protection import AttackProtection

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.blacklists import Blacklists

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.branding import Branding

@@ -75,1 +74,63 @@

)
@mock.patch("auth0.management.branding.RestClient")
def test_get_default_branding_theme(self, mock_rc):
api = mock_rc.return_value
api.get.return_value = {}
branding = Branding(domain="domain", token="jwttoken")
branding.get_default_branding_theme()
api.get.assert_called_with(
"https://domain/api/v2/branding/themes/default",
)
@mock.patch("auth0.management.branding.RestClient")
def test_get_branding_theme(self, mock_rc):
api = mock_rc.return_value
api.get.return_value = {}
branding = Branding(domain="domain", token="jwttoken")
branding.get_branding_theme("theme_id")
api.get.assert_called_with(
"https://domain/api/v2/branding/themes/theme_id",
)
@mock.patch("auth0.management.branding.RestClient")
def test_delete_branding_theme(self, mock_rc):
api = mock_rc.return_value
api.delete.return_value = {}
branding = Branding(domain="domain", token="jwttoken")
branding.delete_branding_theme("theme_id")
api.delete.assert_called_with(
"https://domain/api/v2/branding/themes/theme_id",
)
@mock.patch("auth0.management.branding.RestClient")
def test_update_branding_theme(self, mock_rc):
api = mock_rc.return_value
api.patch.return_value = {}
branding = Branding(domain="domain", token="jwttoken")
branding.update_branding_theme("theme_id", {})
api.patch.assert_called_with(
"https://domain/api/v2/branding/themes/theme_id",
data={},
)
@mock.patch("auth0.management.branding.RestClient")
def test_create_branding_theme(self, mock_rc):
api = mock_rc.return_value
api.post.return_value = {}
branding = Branding(domain="domain", token="jwttoken")
branding.create_branding_theme({})
api.post.assert_called_with(
"https://domain/api/v2/branding/themes",
data={},
)
import unittest
from unittest import mock
import mock
from ...management.client_credentials import ClientCredentials

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.client_grants import ClientGrants

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.clients import Clients

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.connections import Connections

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.custom_domains import CustomDomains

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.device_credentials import DeviceCredentials

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.email_templates import EmailTemplates

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.emails import Emails

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.grants import Grants

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.guardian import Guardian

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.hooks import Hooks

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.jobs import Jobs

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.log_streams import LogStreams

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.logs import Logs

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.organizations import Organizations

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.prompts import Prompts

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.resource_servers import ResourceServers

@@ -6,0 +5,0 @@

@@ -5,4 +5,4 @@ import base64

import unittest
from unittest import mock
import mock
import requests

@@ -795,4 +795,4 @@

self.assertEqual(user_agent, "Python/{}".format(python_version))
self.assertEqual(user_agent, f"Python/{python_version}")
self.assertEqual(auth0_client, client_info)
self.assertEqual(content_type, "application/json")
import unittest
from unittest import mock
import mock
from ...management.roles import Roles

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.rules_configs import RulesConfigs

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.rules import Rules

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.stats import Stats

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.tenants import Tenants

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.tickets import Tickets

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.user_blocks import UserBlocks

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.users_by_email import UsersByEmail

@@ -6,0 +5,0 @@

import unittest
from unittest import mock
import mock
from ...management.users import Users

@@ -329,1 +328,79 @@

)
@mock.patch("auth0.management.users.RestClient")
def test_get_authentication_methods(self, mock_rc):
mock_instance = mock_rc.return_value
u = Users(domain="domain", token="jwttoken")
u.get_authentication_methods("user_id")
mock_instance.get.assert_called_with(
"https://domain/api/v2/users/user_id/authentication-methods"
)
@mock.patch("auth0.management.users.RestClient")
def test_get_authentication_method_by_id(self, mock_rc):
mock_instance = mock_rc.return_value
u = Users(domain="domain", token="jwttoken")
u.get_authentication_method_by_id("user_id", "authentication_method_id")
mock_instance.get.assert_called_with(
"https://domain/api/v2/users/user_id/authentication-methods/authentication_method_id"
)
@mock.patch("auth0.management.users.RestClient")
def test_create_authentication_method(self, mock_rc):
mock_instance = mock_rc.return_value
u = Users(domain="domain", token="jwttoken")
u.create_authentication_method("user_id", {})
mock_instance.post.assert_called_with(
"https://domain/api/v2/users/user_id/authentication-methods", data={}
)
@mock.patch("auth0.management.users.RestClient")
def test_update_authentication_methods(self, mock_rc):
mock_instance = mock_rc.return_value
u = Users(domain="domain", token="jwttoken")
u.update_authentication_methods("user_id", {})
mock_instance.put.assert_called_with(
"https://domain/api/v2/users/user_id/authentication-methods", data={}
)
@mock.patch("auth0.management.users.RestClient")
def test_update_authentication_method_by_id(self, mock_rc):
mock_instance = mock_rc.return_value
u = Users(domain="domain", token="jwttoken")
u.update_authentication_method_by_id("user_id", "authentication_method_id", {})
mock_instance.patch.assert_called_with(
"https://domain/api/v2/users/user_id/authentication-methods/authentication_method_id",
data={},
)
@mock.patch("auth0.management.users.RestClient")
def test_delete_authentication_methods(self, mock_rc):
mock_instance = mock_rc.return_value
u = Users(domain="domain", token="jwttoken")
u.delete_authentication_methods("user_id")
mock_instance.delete.assert_called_with(
"https://domain/api/v2/users/user_id/authentication-methods"
)
@mock.patch("auth0.management.users.RestClient")
def test_delete_authentication_method_by_id(self, mock_rc):
mock_instance = mock_rc.return_value
u = Users(domain="domain", token="jwttoken")
u.delete_authentication_method_by_id("user_id", "authentication_method_id")
mock_instance.delete.assert_called_with(
"https://domain/api/v2/users/user_id/authentication-methods/authentication_method_id"
)

@@ -1,15 +0,11 @@

import sys
def is_async_available():
if sys.version_info >= (3, 6):
try:
import asyncio
try:
import asyncio
import aiohttp
import aiohttp
return True
except ImportError: # pragma: no cover
pass
return True
except ImportError: # pragma: no cover
pass
return False
Metadata-Version: 2.1
Name: auth0-python
Version: 4.0.0
Version: 4.1.0
Summary: Auth0 Python SDK

@@ -55,12 +55,3 @@ Home-page: https://github.com/auth0/auth0-python

[API documentation](https://auth0.com/docs/auth-api).
For example:
```python
from auth0.authentication import Social
social = Social('my-domain.us.auth0.com', 'my-client-id')
social.login(access_token='...', connection='facebook')
```
If you need to sign up a user using their email and password, you can use the Database object.

@@ -67,0 +58,0 @@

@@ -32,12 +32,3 @@ ![Auth0 SDK for Python](https://cdn.auth0.com/website/sdks/banners/auth0-python-banner.png)

[API documentation](https://auth0.com/docs/auth-api).
For example:
```python
from auth0.authentication import Social
social = Social('my-domain.us.auth0.com', 'my-client-id')
social.login(access_token='...', connection='facebook')
```
If you need to sign up a user using their email and password, you can use the Database object.

@@ -44,0 +35,0 @@

@@ -1,2 +0,1 @@

import io
import os

@@ -10,3 +9,3 @@ import re

file_dir = os.path.dirname(__file__)
with io.open(os.path.join(file_dir, "auth0", "__init__.py")) as f:
with open(os.path.join(file_dir, "auth0", "__init__.py")) as f:
version = re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]', f.read())

@@ -19,3 +18,3 @@ if version:

with io.open("README.md", encoding="utf-8") as f:
with open("README.md", encoding="utf-8") as f:
long_description = f.read()

@@ -35,3 +34,3 @@

install_requires=["requests>=2.14.0", "pyjwt[crypto]>=2.6.0"],
extras_require={"test": ["coverage", "mock>=1.3.0", "pre-commit"]},
extras_require={"test": ["coverage", "pre-commit"]},
python_requires=">=3.7",

@@ -38,0 +37,0 @@ classifiers=[