AppAuth-Android icon indicating copy to clipboard operation
AppAuth-Android copied to clipboard

Authorization result intent returns null

Open imartinR2 opened this issue 3 years ago • 10 comments

Checklist:

  • [x] I am using the latest release
  • [x] I searched for existing GitHub issues
  • [x] I read the documentation
  • [x] I verified the client configuration matches the information in the identity provider (or I am using dynamic client registration)
  • [x] I am either using a custom URI scheme or https with App Links for client redirect.
  • [ ] I can reproduce the issue in the demo app (optional)

Configuration

  • Version: 0.11.1
  • Integration: native Java
  • Identity provider: oauth2

Issue Description

Hello. I have my custom Azure login using oauth2 as my identity provider and it's working good. However, I received a recent report that there was an instance were the user could not login, since every time the browser was launched, the immediately entered the onActivityResult of the view, with the intent data as a null, and he couldn't continue because of that. Any idea why that could be happening?

Just to add a bit more data, that issue was only in one phone (a Samsung A21), and whether the app was force closed it didn't mattered, since the problem was still there.

imartinR2 avatar Feb 18 '22 07:02 imartinR2

Authorization result intent returns null. I am also seeing same issue after upgrading app target to API 31....This issue is happening on on devices having API level 31 for devices below API 31 it is working fine...This is reproducible issue.

ThatsNeha avatar Feb 24 '22 07:02 ThatsNeha

Anyone solved this?

kostasmoul avatar Mar 09 '22 23:03 kostasmoul

I think we need to be clear about which intent data is null here. I'm seeing in my cancelIntent:

    override fun onCreate(savedInstanceState: Bundle?) {
        ...
        val ex = AuthorizationException.fromIntent(intent)

that this ex is null. This would normally contain an exception, e.g. AuthorizationException: {"type":0,"code":1,"errorDescription":"User cancelled flow"} for a user-cancelled process. Is that the same data being null you are seeing?

rwst avatar Mar 10 '22 08:03 rwst

Hi @rwst ,

Since this happened in a client phone that I didn't have access to, am not 100% sure, but for what I recall, the intent from the onActivityResult came completely null, not an error code, not anything.

To add a bit more clarity to the issue, here is the code:

 @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        AuthorizationResponse resp = AuthorizationResponse.fromIntent(data); <- This data is null and the app crashes
}

imartinR2 avatar Mar 10 '22 08:03 imartinR2

Ah yes, resp is null here too but this just means the auth is not successful. If the auth is just canceled (e.g. back button) then resp is null as well (I have checked this), with the ex in my code set to an exception. But the ex is null too in my case which seems completely outside the intended behaviour.

rwst avatar Mar 10 '22 09:03 rwst

@rwst Well in my case my problem was that the user couldn't do anything, since every time the user launched the navigator to perform the login, it instantly closed without doing any inputs from the user, and the null intent appeared.

Maybe the problem was with the sessions/cookies stored in the navigator, that there was some kind of issue. To try to fix it, I forced to perform a login every time the activity is launched. So far I have 0 issues reported from it, so let's home that was the issue.

imartinR2 avatar Mar 10 '22 09:03 imartinR2

@rwst Im facing the same issue. Did you find any solution or work around?

5AbhishekSaxena avatar Apr 19 '22 16:04 5AbhishekSaxena

I remember I found a bug in my code but don't remember exactly. You can find my working code as part of https://github.com/rwst/Lichess-by-Voice

rwst avatar Apr 20 '22 07:04 rwst

@kostasmoul @5AbhishekSaxena Perhaps related to device orientation? https://github.com/openid/AppAuth-Android/issues/769#issuecomment-993980294

thijs-qv avatar Jun 13 '22 14:06 thijs-qv

Are you passing FLAG_MUTABLE to intents created for performAuthorizationRequest()?

More info: https://github.com/openid/AppAuth-Android/issues/746

enekonieto avatar Dec 15 '23 16:12 enekonieto