From 4d561a4635a73a668e6f703398768081e4325a19 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 14 May 2024 10:40:17 +0200 Subject: [PATCH] Updated SSO to add client ID & token endpoint URL to auth info --- .../sso/viewmodel/SingleSignOnViewModel.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/src/main/java/org/linphone/ui/main/sso/viewmodel/SingleSignOnViewModel.kt b/app/src/main/java/org/linphone/ui/main/sso/viewmodel/SingleSignOnViewModel.kt index ac0493c77..fe8d236c9 100644 --- a/app/src/main/java/org/linphone/ui/main/sso/viewmodel/SingleSignOnViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/sso/viewmodel/SingleSignOnViewModel.kt @@ -33,6 +33,7 @@ import net.openid.appauth.AuthorizationResponse import net.openid.appauth.AuthorizationService import net.openid.appauth.AuthorizationServiceConfiguration import net.openid.appauth.ResponseTypeValues +import org.json.JSONObject import org.linphone.LinphoneApplication.Companion.coreContext import org.linphone.core.Factory import org.linphone.core.tools.Log @@ -326,6 +327,23 @@ class SingleSignOnViewModel : GenericViewModel() { } authInfo.accessToken = accessToken authInfo.refreshToken = refreshToken + + try { + val data = authState.jsonSerializeString() + val json = JSONObject(data) + val lastTokenResponse = json.getJSONObject("mLastTokenResponse") + val request = lastTokenResponse.getJSONObject("request") + val config = request.getJSONObject("configuration") + val tokenEndpoint = config.getString("tokenEndpoint") + Log.i("$TAG Extracted [$tokenEndpoint] token endpoint URL") + authInfo.tokenEndpointUri = tokenEndpoint + } catch (e: Exception) { + Log.e( + "$TAG Failed to extract tokenEndpoint from lastTokenResponse in AuthState's JSON: $e" + ) + } + + authInfo.clientId = CLIENT_ID core.addAuthInfo(authInfo) Log.i(