Skip to content
1 change: 1 addition & 0 deletions auth0/authentication/back_channel_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ def back_channel_login(
"scope": scope,
**kwargs,
},
headers={"Content-Type": "application/x-www-form-urlencoded"},
)
60 changes: 60 additions & 0 deletions auth0/test/authentication/test_back_channel_login.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import unittest
from unittest import mock
import json

import requests
from ...exceptions import Auth0Error, RateLimitError
Expand Down Expand Up @@ -74,5 +75,64 @@ def test_should_require_scope(self, mock_post):
# Assert the error message is correct
self.assertIn("missing 1 required positional argument: \'scope\'", str(context.exception))

@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)
)



Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_par_custom_params(self, mock_post):
)

@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!")
a.pushed_authorization_request(
response_type="code",
Expand Down
Loading