openid / AppAuth-Android

Android client SDK for communicating with OAuth 2.0 and OpenID Connect providers.
https://openid.github.io/AppAuth-Android
Apache License 2.0
2.77k stars 873 forks source link

After changing device language gives login_required error #1021

Open WK-shahnawaz-khan opened 7 months ago

WK-shahnawaz-khan commented 7 months ago

Checklist:

Configuration

Issue Description

I have successfully logged in with OAuth2 and everything working fine. but as soon as I change device language and when i try to authenticate it gives me AuthorizationException: {"type":1,"code":1008,"error":"login_required"} in android API 33, however same process working fine in API 30 and below

code snippet

val authRequestBuilder = AuthorizationRequest.Builder(
            authServiceConfiguration(),
            configs.client_ID
            ResponseTypeValues.CODE,
            Uri.parse(configs.callback_url) // Redirect URI
        ).setScope("openid profile offline_access")
            .setState("12345678")
            .setClientId(configs.client_ID)
            .setPrompt(AuthorizationRequest.Prompt.NONE)
            .setAdditionalParameters(mapOf(Pair("additional_param", "id")))
            .build()

        authService = AuthorizationService(context)
        val authIntent =  authService.getAuthorizationRequestIntent(authRequestBuilder)

authResultLauncher.launch(authIntent)

 private val authResultLauncher =
        registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
            val data: Intent? = result.data
            data?.let {
                val authorizationResponse = AuthorizationResponse.fromIntent(it)
                val exception = AuthorizationException.fromIntent(data)
                if (result.resultCode == Activity.RESULT_OK) {
                    if (authorizationResponse != null) {
                     // business logic
                    } else {
                   // exception
                    }
                } else {
                 // exception
                }
            } ?: kotlin.run {
                // exception
            }
        }