Skip to content

Commit e341e3b

Browse files
feat: Add optional state parameter to AuthorizationCode and update PARCodeManager to handle it
1 parent 3dba49a commit e341e3b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

auth0/src/main/java/com/auth0/android/provider/PARCodeManager.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ internal class PARCodeManager(
2727
private const val KEY_CLIENT_ID = "client_id"
2828
private const val KEY_REQUEST_URI = "request_uri"
2929
private const val KEY_CODE = "code"
30+
private const val KEY_STATE = "state"
3031
private const val KEY_ERROR = "error"
3132
private const val KEY_ERROR_DESCRIPTION = "error_description"
3233
private const val ERROR_VALUE_ACCESS_DENIED = "access_denied"
@@ -81,8 +82,11 @@ internal class PARCodeManager(
8182
return true
8283
}
8384

84-
// Success - return authorization code
85-
val authorizationCode = AuthorizationCode(code = code)
85+
// Extract optional state
86+
val state = values[KEY_STATE]
87+
88+
// Success - return authorization code with optional state
89+
val authorizationCode = AuthorizationCode(code = code, state = state)
8690
callback.onSuccess(authorizationCode)
8791
return true
8892
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ package com.auth0.android.result
66
* handles the token exchange.
77
*
88
* @property code The authorization code from the callback
9+
* @property state The optional state parameter from the callback, if present
910
*/
1011
public data class AuthorizationCode(
1112
/**
1213
* The authorization code received from Auth0.
1314
* This code should be sent to your BFF for token exchange.
1415
*/
15-
public val code: String
16+
public val code: String,
17+
18+
/**
19+
* The optional state parameter received from Auth0.
20+
* This can be used by the BFF to correlate the response with the original request.
21+
*/
22+
public val state: String? = null
1623
)

0 commit comments

Comments
 (0)