MaikuB / flutter_appauth

A Flutter wrapper for AppAuth iOS and Android SDKs
275 stars 245 forks source link

App stuck with 302 redirect and unable to log in with the OAuth2 provider #403

Open jairwt opened 1 year ago

jairwt commented 1 year ago

The login flow is not continuing in the mobile app. (302 http code is being returned by /oauth2/userAuthorize with no follow up from mobile app in some android devices).

Your Environment

Plugin version: 4.2.0 Platform: Android Flutter info (flutter doctor): Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.3.6, on macOS 12.6 21G115 darwin-arm (Rosetta), locale en-GB) [!] Android toolchain - develop for Android devices (Android SDK version 30.0.2) [✓] Xcode - develop for iOS and macOS (Xcode 14.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.3) [✓] VS Code (version 1.73.1) [✓] Connected device (3 available) [✓] HTTP Host Availability

Context

  1. AppAuth opens new customs tab (previously the user was in the native Android app)
  2. User click on login button.
  3. The server directly returns a 302 with a redirect, and the app get stuck.

Expected Behaviour :

  1. Chrome tabs should be closed, and the app should catch the intent and user should be able to log in after redirecting to the app login screen.

Actual Behaviour :

  1. Chrome tabs did not close. The app did not catch the intent and the user was unable to log in with the OAuth2 provider.
  2. Chrome tab close and nothing happened, no callback and follow up happen in the app and user is not able to login.
MaikuB commented 1 year ago

Issues like this are symptomatic of configuration not being done properly so would be something you'll have to look into further as this dependent on your app and IdP. You may also need to check that whatever server you're using is follow specific standards as the plugin itself leverages native SDKs maintained by others that implements an industry standard specification so I'm doubtful it's an issue with the plugin/SDKs. Furthermore, the example app also shows this is working properly and others in the community have successfully used the plugin with major IdPs from companies like Google, Auth0, Microsoft etc

Joren-Thijs-KasparSolutions commented 1 year ago

@jairwt i was facing the exact same issue on Android. Turned out to configure universal links on Android you need to define a seperate activity in you AndroidManifest.xml and put your intentfilter there. Putting it on the MainActivity intent doesn't work. Maybe you have the same configuration problem?

https://stackoverflow.com/questions/75873663/data-intent-is-null-in-android-using-universal-links-applinks-using-react-native

tricasthu commented 1 year ago

I could reproduce this issue with Brave as the default browser on my Android device.

Flutter doctor:

PS C:\Users\...> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.7.12, on Microsoft Windows [Version 10.0.19045.3324], locale hu-HU)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2022.1)
[√] Android Studio (version 2022.2)
[√] IntelliJ IDEA Community Edition (version 2023.1)
[√] VS Code (version 1.81.1)
[√] Connected device (5 available)
[√] HTTP Host Availability

! Doctor found issues in 2 categories.

Device: Samsung Galaxy A41, Android 12, OneUI 4.1 Brave: 1.57.53, latest as of writing

I noticed this problem in a custom app, and after searching for a cause I narrowed it down to Brave. Changing the default browser to Chrome solves this issue, however, that could not be a solution. On iOS it is working fine. I tried the example app, "Sign in with auto code exchange" which also fails with Brave. Disabling Brave Shields did not help.

karuppasamy567 commented 10 months ago

i am not able to run sample code

issue