Skip to content

Commit 0ea3a10

Browse files
committed
feat: Added support for organisation in CTE
1 parent 5785a50 commit 0ea3a10

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

auth0/src/main/java/com/auth0/android/authentication/AuthenticationAPIClient.kt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -749,13 +749,15 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
749749
*
750750
* @param subjectTokenType the subject token type that is associated with the existing Identity Provider. e.g. 'http://acme.com/legacy-token'
751751
* @param subjectToken the subject token, typically obtained through the Identity Provider's SDK
752+
* @param organization id of the organization the user belongs to
752753
* @return a request to configure and start that will yield [Credentials]
753754
*/
754755
public fun customTokenExchange(
755756
subjectTokenType: String,
756757
subjectToken: String,
758+
organization: String? = null
757759
): AuthenticationRequest {
758-
return tokenExchange(subjectTokenType, subjectToken)
760+
return tokenExchange(subjectTokenType, subjectToken, organization)
759761
}
760762

761763
/**
@@ -1043,13 +1045,17 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
10431045
*/
10441046
private fun tokenExchange(
10451047
subjectTokenType: String,
1046-
subjectToken: String
1048+
subjectToken: String,
1049+
organization: String? = null
10471050
): AuthenticationRequest {
1048-
val parameters = ParameterBuilder.newAuthenticationBuilder()
1049-
.setGrantType(ParameterBuilder.GRANT_TYPE_TOKEN_EXCHANGE)
1050-
.set(SUBJECT_TOKEN_TYPE_KEY, subjectTokenType)
1051-
.set(SUBJECT_TOKEN_KEY, subjectToken)
1052-
.asDictionary()
1051+
val parameters = ParameterBuilder.newAuthenticationBuilder().apply {
1052+
setGrantType(ParameterBuilder.GRANT_TYPE_TOKEN_EXCHANGE)
1053+
set(SUBJECT_TOKEN_TYPE_KEY, subjectTokenType)
1054+
set(SUBJECT_TOKEN_KEY, subjectToken)
1055+
organization?.let {
1056+
set(ORGANIZATION_KEY, it)
1057+
}
1058+
}.asDictionary()
10531059
return loginWithToken(parameters)
10541060
}
10551061

0 commit comments

Comments
 (0)