Skip to content

Commit bd87beb

Browse files
committed
updated the session token type to the newly defined one
1 parent 9638740 commit bd87beb

File tree

7 files changed

+23
-18
lines changed

7 files changed

+23
-18
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
938938
.setGrantType(ParameterBuilder.GRANT_TYPE_TOKEN_EXCHANGE)
939939
.set(SUBJECT_TOKEN_KEY, refreshToken)
940940
.set(SUBJECT_TOKEN_TYPE_KEY, ParameterBuilder.TOKEN_TYPE_REFRESH_TOKEN)
941-
.set(REQUESTED_TOKEN_TYPE_KEY, ParameterBuilder.TOKEN_TYPE_SESSION_TOKEN)
941+
.set(REQUESTED_TOKEN_TYPE_KEY, ParameterBuilder.TOKEN_TYPE_SESSION_TRANSFER_TOKEN)
942942
.asDictionary()
943943
return loginWithTokenGeneric<SSOCredentials>(params)
944944
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public class ParameterBuilder private constructor(parameters: Map<String, String
161161
"urn:ietf:params:oauth:grant-type:token-exchange"
162162
public const val GRANT_TYPE_PASSKEY :String = "urn:okta:params:oauth:grant-type:webauthn"
163163
public const val TOKEN_TYPE_REFRESH_TOKEN :String = "urn:ietf:params:oauth:token-type:refresh_token"
164-
public const val TOKEN_TYPE_SESSION_TOKEN :String = "urn:auth0:params:oauth:token-type:session_token"
164+
public const val TOKEN_TYPE_SESSION_TRANSFER_TOKEN :String = "urn:auth0:params:oauth:token-type:session_transfer_token"
165165
public const val SCOPE_OPENID: String = "openid"
166166
public const val SCOPE_OFFLINE_ACCESS: String = "openid offline_access"
167167
public const val SCOPE_KEY: String = "scope"

auth0/src/main/java/com/auth0/android/authentication/storage/BaseCredentialsManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public abstract class BaseCredentialsManager internal constructor(
3232
public abstract fun saveCredentials(credentials: Credentials)
3333
public abstract fun getCredentials(callback: Callback<Credentials, CredentialsManagerException>)
3434
public abstract fun getSsoCredentials(
35-
headers: Map<String, String>,
35+
parameters: Map<String, String>,
3636
callback: Callback<SSOCredentials, CredentialsManagerException>
3737
)
3838

@@ -72,7 +72,7 @@ public abstract class BaseCredentialsManager internal constructor(
7272

7373
@JvmSynthetic
7474
@Throws(CredentialsManagerException::class)
75-
public abstract suspend fun awaitSsoCredentials(headers: Map<String, String>)
75+
public abstract suspend fun awaitSsoCredentials(parameters: Map<String, String>)
7676
: SSOCredentials
7777

7878
@JvmSynthetic

auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManager.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class CredentialsManager @VisibleForTesting(otherwise = VisibleForTesting
7474
*/
7575
@ExperimentalAuth0Api
7676
override fun getSsoCredentials(
77-
headers: Map<String, String>,
77+
parameters: Map<String, String>,
7878
callback: Callback<SSOCredentials, CredentialsManagerException>
7979
) {
8080
serialExecutor.execute {
@@ -86,8 +86,8 @@ public class CredentialsManager @VisibleForTesting(otherwise = VisibleForTesting
8686

8787
val request = authenticationClient.fetchWebSsoToken(refreshToken)
8888
try {
89-
for (header in headers) {
90-
request.addHeader(header.key, header.value)
89+
if (parameters.isNotEmpty()) {
90+
request.addParameters(parameters)
9191
}
9292
val sessionCredentials = request.execute()
9393
saveSsoCredentials(sessionCredentials)
@@ -132,9 +132,9 @@ public class CredentialsManager @VisibleForTesting(otherwise = VisibleForTesting
132132
@JvmSynthetic
133133
@Throws(CredentialsManagerException::class)
134134
@ExperimentalAuth0Api
135-
override suspend fun awaitSsoCredentials(headers: Map<String, String>): SSOCredentials {
135+
override suspend fun awaitSsoCredentials(parameters: Map<String, String>): SSOCredentials {
136136
return suspendCancellableCoroutine { continuation ->
137-
getSsoCredentials(headers,
137+
getSsoCredentials(parameters,
138138
object : Callback<SSOCredentials, CredentialsManagerException> {
139139
override fun onSuccess(result: SSOCredentials) {
140140
continuation.resume(result)

auth0/src/main/java/com/auth0/android/authentication/storage/SecureCredentialsManager.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
148148
*/
149149
@ExperimentalAuth0Api
150150
override fun getSsoCredentials(
151-
headers: Map<String, String>,
151+
parameters: Map<String, String>,
152152
callback: Callback<SSOCredentials, CredentialsManagerException>
153153
) {
154154
serialExecutor.execute {
@@ -166,8 +166,8 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
166166

167167
val request = authenticationClient.fetchWebSsoToken(existingCredentials.refreshToken!!)
168168
try {
169-
for (header in headers) {
170-
request.addHeader(header.key, header.value)
169+
if (parameters.isNotEmpty()) {
170+
request.addParameters(parameters)
171171
}
172172
val sessionCredentials =
173173
request.execute()
@@ -218,9 +218,9 @@ public class SecureCredentialsManager @VisibleForTesting(otherwise = VisibleForT
218218
@JvmSynthetic
219219
@Throws(CredentialsManagerException::class)
220220
@ExperimentalAuth0Api
221-
override suspend fun awaitSsoCredentials(headers: Map<String, String>): SSOCredentials {
221+
override suspend fun awaitSsoCredentials(parameters: Map<String, String>): SSOCredentials {
222222
return suspendCancellableCoroutine { continuation ->
223-
getSsoCredentials(headers,
223+
getSsoCredentials(parameters,
224224
object : Callback<SSOCredentials, CredentialsManagerException> {
225225
override fun onSuccess(result: SSOCredentials) {
226226
continuation.resume(result)

auth0/src/main/java/com/auth0/android/result/SSOCredentials.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,9 @@ public data class SSOCredentials(
5151
* @return the Refresh Token.
5252
*/
5353
@field:SerializedName("refresh_token") public val refreshToken: String? = null
54-
)
54+
) {
55+
56+
override fun toString(): String {
57+
return "SSOCredentials(webSsoToken = ****, issuedTokenType = $issuedTokenType, tokenType = $tokenType, expiresIn = $expiresIn, refreshToken = ****)"
58+
}
59+
}

auth0/src/test/java/com/auth0/android/authentication/AuthenticationAPIClientTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,7 +2376,7 @@ public class AuthenticationAPIClientTest {
23762376
)
23772377
assertThat(body, Matchers.hasEntry("subject_token", "refresh-token"))
23782378
assertThat(body, Matchers.hasEntry("subject_token_type", ParameterBuilder.TOKEN_TYPE_REFRESH_TOKEN))
2379-
assertThat(body, Matchers.hasEntry("requested_token_type", ParameterBuilder.TOKEN_TYPE_SESSION_TOKEN))
2379+
assertThat(body, Matchers.hasEntry("requested_token_type", ParameterBuilder.TOKEN_TYPE_SESSION_TRANSFER_TOKEN))
23802380
assertThat(
23812381
callback, AuthenticationCallbackMatcher.hasPayloadOfType(
23822382
SSOCredentials::class.java
@@ -2404,7 +2404,7 @@ public class AuthenticationAPIClientTest {
24042404
)
24052405
assertThat(body, Matchers.hasEntry("subject_token", "refresh-token"))
24062406
assertThat(body, Matchers.hasEntry("subject_token_type", ParameterBuilder.TOKEN_TYPE_REFRESH_TOKEN))
2407-
assertThat(body, Matchers.hasEntry("requested_token_type", ParameterBuilder.TOKEN_TYPE_SESSION_TOKEN))
2407+
assertThat(body, Matchers.hasEntry("requested_token_type", ParameterBuilder.TOKEN_TYPE_SESSION_TRANSFER_TOKEN))
24082408
assertThat(ssoCredentials, Matchers.`is`(Matchers.notNullValue()))
24092409
}
24102410

@@ -2430,7 +2430,7 @@ public class AuthenticationAPIClientTest {
24302430
)
24312431
assertThat(body, Matchers.hasEntry("subject_token", "refresh-token"))
24322432
assertThat(body, Matchers.hasEntry("subject_token_type", ParameterBuilder.TOKEN_TYPE_REFRESH_TOKEN))
2433-
assertThat(body, Matchers.hasEntry("requested_token_type", ParameterBuilder.TOKEN_TYPE_SESSION_TOKEN))
2433+
assertThat(body, Matchers.hasEntry("requested_token_type", ParameterBuilder.TOKEN_TYPE_SESSION_TRANSFER_TOKEN))
24342434
assertThat(ssoCredentials, Matchers.`is`(Matchers.notNullValue()))
24352435
}
24362436

0 commit comments

Comments
 (0)