Open
Description
Configuration
- Version: 011.1
- Integration: Android native(Kotlin) API 34
- Identity provider: KeyCloak 26.1.4
Hi everyone,
Objective:
Trying to make an android app to authenticate with Keycloak using PKCE
Issue:
AuthorizationResponse.fromIntent(intent) is getting null in the app's redirectedActivity page.
Processes:
1) Android app is able to launch the keycloak login page using the following codes:
val authRequest = AuthorizationRequest.Builder(
serviceConfiguration,
Config.CLIENT_ID,
ResponseTypeValues.CODE,
Uri.parse(Config.REDIRECT_URI)
)
.setCodeVerifier(codeVerifier, codeChallenge, CODE_CHALLENGE)
.setScope(Config.SCOPE)
.build()
val authRequestUrl = authRequest.toUri()
val intent = Intent(Intent.ACTION_VIEW, authRequestUrl)
context.startActivity(intent)
onResult(Result.success(authRequestUrl))
2) Keycloak page launched and able to login and the event in keycloak showed "LOGIN" is successful.
3) Once submitted, the redirectedPage configured in Android Manifest was triggered and able to trace that the oncreate method is called and AuthorzationResponse.fromIntent is null. Below is the code.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val response = AuthorizationResponse.fromIntent(intent) -> null
val exception = AuthorizationException.fromIntent(intent)
}
4) The content of the Intent is as follows:
example.com://oauth2redirect?state=-Dzehoz8zpfl7IhpXxbk2Q&session_state=b2ef796a-2638-41df-82a5-fea05977836b&iss=http%3A%2F%2F10.0.2.2%3A8080%2Frealms%2FABC&code=ce4ccbf6-4f62-45ae-8225-1065a825915b.b2ef796a-2638-41df-82a5-fea05977836b.6b4880e0-0592-4ba4-b6bb-d655e9d0a5ac
There isn't anything in the Extras.
Appreciate if anyone can highlight what is wrong?
Thank you very much for your help.