@@ -334,4 +334,49 @@ def test_backchannel_login(self, mock_post):
334334 "auth_req_id" : "reqid" ,
335335 "grant_type" : "urn:openid:params:grant-type:ciba" ,
336336 },
337- )
337+ )
338+
339+ @mock .patch ("auth0.rest.RestClient.post" )
340+ def test_federated_connection_token (self , mock_post ):
341+
342+
343+ g = GetToken ("my.domain.com" , "<client_id>" , client_secret = "<client_secret>" )
344+
345+ g .federated_connection_token (refresh_token = '<refresh_token>' , connection = '<connection_name>' )
346+
347+ args , kwargs = mock_post .call_args
348+
349+ self .assertEqual (args [0 ], "https://my.domain.com/oauth/token" )
350+ self .assertEqual (
351+ kwargs ["data" ],
352+ {
353+ "client_id" : "<client_id>" ,
354+ "client_secret" : "<client_secret>" ,
355+ "grant_type" : "urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token" ,
356+ "connection" : "<connection_name>" ,
357+ "subject_token" : "<refresh_token>" ,
358+ "subject_token_type" : "urn:ietf:params:oauth:token-type:refresh_token" ,
359+ "requested_token_type" : "http://auth0.com/oauth/token-type/federated-connection-access-token" ,
360+ }
361+ )
362+
363+
364+ # Get a new federated connection access token with a login hint
365+ g .federated_connection_token (refresh_token = '<refresh_token>' , connection = '<connection_name>' , login_hint = '<login_hint>' )
366+
367+ args , kwargs = mock_post .call_args
368+
369+ self .assertEqual (args [0 ], "https://my.domain.com/oauth/token" )
370+ self .assertEqual (
371+ kwargs ["data" ],
372+ {
373+ "client_id" : "<client_id>" ,
374+ "client_secret" : "<client_secret>" ,
375+ "grant_type" : "urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token" ,
376+ "connection" : "<connection_name>" ,
377+ "subject_token" : "<refresh_token>" ,
378+ "subject_token_type" : "urn:ietf:params:oauth:token-type:refresh_token" ,
379+ "requested_token_type" : "http://auth0.com/oauth/token-type/federated-connection-access-token" ,
380+ 'login_hint' : '<login_hint>' ,
381+ }
382+ )
0 commit comments