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.8.1
to
4.9.0
+1
-1
auth0/__init__.py
# This value is updated by `poetry_dynamic_versioning` during build time from the latest git tag
__version__ = "4.8.1"
__version__ = "4.9.0"

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

@@ -37,2 +37,3 @@ from typing import Any

},
headers={"Content-Type": "application/x-www-form-urlencoded"},
)

@@ -279,2 +279,37 @@ from __future__ import annotations

},
)
def access_token_for_connection(
self,
subject_token_type: str,
subject_token: str,
requested_token_type: str,
connection: str | None = None,
grant_type: str = "urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token"
) -> Any:
"""Calls /oauth/token endpoint with federated-connection-access-token grant type
Args:
subject_token_type (str): String containing the type of token.
subject_token (str): String containing the value of subject_token_type.
requested_token_type (str): String containing the type of rquested token.
connection (str, optional): Denotes the name of a social identity provider configured to your application
Returns:
access_token, scope, issued_token_type, token_type
"""
return self.authenticated_post(
f"{self.protocol}://{self.domain}/oauth/token",
data={
"client_id": self.client_id,
"grant_type": grant_type,
"subject_token_type": subject_token_type,
"subject_token": subject_token,
"requested_token_type": requested_token_type,
"connection": connection,
},
)

@@ -540,2 +540,45 @@ from __future__ import annotations

url = self._url(f"{user_id}/authentication-methods/{authentication_method_id}")
return self.client.delete(url)
return self.client.delete(url)
def list_tokensets(
self, id: str, page: int = 0, per_page: int = 25, include_totals: bool = True
):
"""List all the tokenset(s) associated to the user.
Args:
id (str): The user's id.
page (int, optional): The result's page number (zero based). By default,
retrieves the first page of results.
per_page (int, optional): The amount of entries per page. By default,
retrieves 25 results per page.
include_totals (bool, optional): True if the query summary is
to be included in the result, False otherwise. Defaults to True.
See https://auth0.com/docs/api/management/v2#!/Users/get_tokensets
"""
params = {
"per_page": per_page,
"page": page,
"include_totals": str(include_totals).lower(),
}
url = self._url(f"{id}/federated-connections-tokensets")
return self.client.get(url, params=params)
def delete_tokenset_by_id(
self, user_id: str, tokenset_id: str
) -> Any:
"""Deletes an tokenset by ID.
Args:
user_id (str): The user_id to delete an authentication method by ID for.
tokenset_id (str): The tokenset_id to delete an tokenset by ID for.
See: https://auth0.com/docs/api/management/v2#!/Users/delete_tokenset_by_id
"""
url = self._url(f"{user_id}/federated-connections-tokensets/{tokenset_id}")
return self.client.delete(url)
import unittest
from unittest import mock
import json

@@ -77,3 +78,62 @@ import requests

@mock.patch("auth0.rest.RestClient.post")
def test_with_authorization_details(self, mock_post):
g = BackChannelLogin("my.domain.com", "cid", client_secret="clsec")
g.back_channel_login(
binding_message="This is a binding message.",
login_hint={"format": "iss_sub", "iss": "https://my.domain.auth0.com/", "sub": "auth0|USER_ID"},
scope="openid",
authorization_details=[
{
"type":"payment_initiation","locations":["https://example.com/payments"],
"instructedAmount":
{
"currency":"EUR","amount":"123.50"
},
"creditorName":"Merchant A",
"creditorAccount":
{
"bic":"ABCIDEFFXXX",
"iban":"DE021001001093071118603"
},
"remittanceInformationUnstructured":"Ref Number Merchant"
}
],
)
args, kwargs = mock_post.call_args
expected_data = {
"client_id": "cid",
"client_secret": "clsec",
"binding_message": "This is a binding message.",
"login_hint": {"format": "iss_sub", "iss": "https://my.domain.auth0.com/", "sub": "auth0|USER_ID" },
"scope": "openid",
"authorization_details": [
{
"type":"payment_initiation","locations":["https://example.com/payments"],
"instructedAmount":
{
"currency":"EUR","amount":"123.50"
},
"creditorName":"Merchant A",
"creditorAccount":
{
"bic":"ABCIDEFFXXX",
"iban":"DE021001001093071118603"
},
"remittanceInformationUnstructured":"Ref Number Merchant"
}],
}
actual_data = kwargs["data"]
self.assertEqual(args[0], "https://my.domain.com/bc-authorize")
self.assertEqual(
json.dumps(actual_data, sort_keys=True),
json.dumps(expected_data, sort_keys=True)
)

@@ -337,2 +337,32 @@ import unittest

},
)
@mock.patch("auth0.rest.RestClient.post")
def test_connection_login(self, mock_post):
g = GetToken("my.domain.com", "cid", client_secret="csec")
g.access_token_for_connection(
grant_type="urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token",
subject_token_type="urn:ietf:params:oauth:token-type:refresh_token",
subject_token="refid",
requested_token_type="http://auth0.com/oauth/token-type/federated-connection-access-token",
connection="google-oauth2"
)
args, kwargs = mock_post.call_args
print(kwargs["data"])
self.assertEqual(args[0], "https://my.domain.com/oauth/token")
self.assertEqual(
kwargs["data"],
{
"grant_type": "urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token",
"client_id": "cid",
"client_secret": "csec",
"subject_token_type": "urn:ietf:params:oauth:token-type:refresh_token",
"subject_token": "refid",
"requested_token_type": "http://auth0.com/oauth/token-type/federated-connection-access-token",
"connection": "google-oauth2"
},
)

@@ -51,3 +51,3 @@ import unittest

@mock.patch("auth0.rest.RestClient.post")
def test_rar(self, mock_post):
def test_with_authorization_details(self, mock_post):
a = PushedAuthorizationRequests("my.domain.com", "cid", client_secret="sh!")

@@ -54,0 +54,0 @@ a.pushed_authorization_request(

@@ -405,2 +405,35 @@ import unittest

"https://domain/api/v2/users/user_id/authentication-methods/authentication_method_id"
)
@mock.patch("auth0.management.users.RestClient")
def test_list_tokensets(self, mock_rc):
mock_instance = mock_rc.return_value
u = Users(domain="domain", token="jwttoken")
u.list_tokensets("an-id")
args, kwargs = mock_instance.get.call_args
self.assertEqual("https://domain/api/v2/users/an-id/federated-connections-tokensets", args[0])
self.assertEqual(
kwargs["params"], {"per_page": 25, "page": 0, "include_totals": "true"}
)
u.list_tokensets(id="an-id", page=1, per_page=50, include_totals=False)
args, kwargs = mock_instance.get.call_args
self.assertEqual("https://domain/api/v2/users/an-id/federated-connections-tokensets", args[0])
self.assertEqual(
kwargs["params"], {"per_page": 50, "page": 1, "include_totals": "false"}
)
@mock.patch("auth0.management.users.RestClient")
def test_delete_tokenset_by_id(self, mock_rc):
mock_instance = mock_rc.return_value
u = Users(domain="domain", token="jwttoken")
u.delete_tokenset_by_id("user_id", "tokenset_id")
mock_instance.delete.assert_called_with(
"https://domain/api/v2/users/user_id/federated-connections-tokensets/tokenset_id"
)
Metadata-Version: 2.1
Name: auth0-python
Version: 4.8.1
Version: 4.9.0
Summary:

@@ -5,0 +5,0 @@ Home-page: https://auth0.com

@@ -7,3 +7,3 @@ [build-system]

name = "auth0-python"
version = "4.8.1" # This is replaced by dynamic versioning
version = "4.9.0" # This is replaced by dynamic versioning
description = ""

@@ -10,0 +10,0 @@ authors = ["Auth0 <support@auth0.com>"]