Open Smedzlatko opened 6 years ago
We had this same issue and resolved it by using an activity context for a one off instance of AuthorizationService
just in our login activity and cleaning it up in onStop
. We inject the one based on application context everywhere else.
I should probably expose a variant of getAuthorizationRequestIntent
that allows you to specify the completion and cancelation PendingIntents, so that you can call startActivity
yourself with the correct context. Alternatively, I could allow the context to be overridden with a parameter passed to performAuthorizationRequest
.
Hi, What is the recommended way of doing this? I am stuck on this error and can't seem to find a way to get around this.
Any news?
Someone already figured out a workaround? We also encapsulated the entire authorization process into a separate module, while using KOIN to inject the androidContext
.
The workaround is already mentioned by @clenthorne: https://github.com/openid/AppAuth-Android/issues/333#issuecomment-384731640
You need to maintain two different flavours of AuthorizationService: One that takes an Activity and is recreated for each new Activity instance. This one is used to launch Custom tabs. One that takes application context and is created once for the app. This one is used for making authorized network requests.
If you are using a DI framework you can solve this by using two different Qualifier annotation classes for the different flavours.
We had this same issue and resolved it by using an activity context for a one off instance of
AuthorizationService
just in our login activity and cleaning it up inonStop
. We inject the one based on application context everywhere else.
this approach is not working for me, i can't bypass the crash at all
We had this same issue and resolved it by using an activity context for a one off instance of
AuthorizationService
just in our login activity and cleaning it up inonStop
. We inject the one based on application context everywhere else.
If that is the intended solution, I think it would be great if AuthorizationService
had a super class that is intended to be initialized by an application Context.
I suddently ran into a weird issue when running AppAuth in my android app in an emulator. Everything works fine on phone, as far as I am concerned but the following exception is thrown inside emulator:
I tracked the issue down and we are not injecting activity context into the auth state manager and it is apparently needed. We are using KOIN for dependency injection (including context) and all our AppAuth services are injected via Koin.
Is there some workaround that would enable us running AppAuth with application context (that's the one being injected)? Setting the
FLAG_NEW_TASK
to the auth intent does not work, unfortunately.Thank you for the clarification.