@@ -457,7 +457,7 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
457457 * @return a request to configure and start that will yield [Credentials]
458458 */
459459 public fun loginWithNativeSocialToken (token : String , tokenType : String ): AuthenticationRequest {
460- return customTokenExchange (tokenType, token)
460+ return tokenExchange (tokenType, token)
461461 }
462462
463463 /* *
@@ -726,12 +726,7 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
726726 subjectTokenType : String ,
727727 subjectToken : String ,
728728 ): AuthenticationRequest {
729- val parameters = ParameterBuilder .newAuthenticationBuilder()
730- .setGrantType(ParameterBuilder .GRANT_TYPE_TOKEN_EXCHANGE )
731- .set(SUBJECT_TOKEN_TYPE_KEY , subjectTokenType)
732- .set(SUBJECT_TOKEN_KEY , subjectToken)
733- .asDictionary()
734- return loginWithToken(parameters)
729+ return tokenExchange(subjectTokenType, subjectToken)
735730 }
736731
737732 /* *
@@ -949,6 +944,21 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
949944 return request
950945 }
951946
947+ /* *
948+ * Helper function to make a request to the /oauth/token endpoint with the token exchange grant type.
949+ */
950+ private fun tokenExchange (
951+ subjectTokenType : String ,
952+ subjectToken : String
953+ ): AuthenticationRequest {
954+ val parameters = ParameterBuilder .newAuthenticationBuilder()
955+ .setGrantType(ParameterBuilder .GRANT_TYPE_TOKEN_EXCHANGE )
956+ .set(SUBJECT_TOKEN_TYPE_KEY , subjectTokenType)
957+ .set(SUBJECT_TOKEN_KEY , subjectToken)
958+ .asDictionary()
959+ return loginWithToken(parameters)
960+ }
961+
952962 private fun profileRequest (): Request <UserProfile , AuthenticationException > {
953963 val url =
954964 auth0.getDomainUrl().toHttpUrl().newBuilder()
0 commit comments