• Home
  • Categories
  • Recent
  • Popular
  • Pricing
  • Contact us
  • Docs
  • Login
FusionAuth
  • Home
  • Categories
  • Recent
  • Popular
  • Pricing
  • Contact us
  • Docs
  • Login

Why doesn't the example flutter demo code from github work on Android?

Scheduled Pinned Locked Moved Solved
Q&A
3
6
9.0k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    david
    last edited by 27 Jun 2022, 10:16

    Hi all,

    I've been following the tutorial for using FusionAuth in a flutter app here: https://fusionauth.io/blog/2020/11/23/securing-flutter-oauth

    Using this code works perfectly in iOS, but doesn't work on my Android device (Google Pixel 6, Firefox browser).

    So I tried downloading the sample project from https://github.com/FusionAuth/fusionauth-example-flutter-dart/, and substituting my own values for the FusionAuth domain, etc. Again, this works perfectly in iOS, but on Android I never get redirected back to the app.

    There is some information here https://fusionauth.io/community/forum/topic/602/error-fusionauth-s-login-page-redirecting-issue-on-android/5 about creating an interstitial web page to complete the redirect to the app for Android devices. Is this really required? Or is there some step I'm missing here that will make this work for an Android app directly without needing to set up a special web page?

    Thanks,

    David

    D 1 Reply Last reply 9 Jul 2022, 13:47 Reply Quote 0
    • D
      dan @david
      last edited by 9 Jul 2022, 13:47

      @david Hmmm. I'm not sure why it doesn't work. Those examples leverage the flutter_appauth library, which in turn depends on the respective appauth libraries:

      https://github.com/openid/AppAuth-Android
      https://github.com/openid/AppAuth-iOS

      It also has been a while since those applications were refreshed, so it is possible that there have been behavior changes. I'll add a todo to review these sample apps, but I'd probably try upgrading to later versions of those underlying libraries and see if that resolves the issue.

      --
      FusionAuth - Auth for devs, built by devs.
      https://fusionauth.io

      D 1 Reply Last reply 12 Jul 2022, 12:34 Reply Quote 0
      • D
        david @dan
        last edited by 12 Jul 2022, 12:34

        Hi @dan,

        Thanks for your response. We are currently using the latest available version of the flutter_appauth package v4.0.1 and still seeing this behaviour. It would be great to see the sample apps reviewed and updated if required. We're currently struggling to get this to work on Android, any help you can give would be greatly appreciated.

        Thanks,

        David

        D 1 Reply Last reply 13 Jul 2022, 09:48 Reply Quote 1
        • D
          david @david
          last edited by david 13 Jul 2022, 09:48

          Hi @dan,

          I think we've found the issue. In the FusionAuth blog post, the appAuthRedirectScheme includes the "://login-callback" part. Removing this seems to fix the issue, and the redirect works correctly.

          The current code in the blog looks like this:

          manifestPlaceholders = [
                'appAuthRedirectScheme': 'com.fusionauth.flutterdemo://login-callback'
              ]
          

          The code could still use a review, though, as there are some other things that are out of date. For example, the above code should use += instead of =, as with later versions of flutter using just = causes an error. See the Android Setup section here https://pub.dev/packages/flutter_appauth for details.

          So the correct, up-to-date code looks like this:

          manifestPlaceholders += [
                'appAuthRedirectScheme': 'com.fusionauth.flutterdemo'
              ]
          

          Thanks,

          David

          D 1 Reply Last reply 13 Jul 2022, 11:00 Reply Quote 1
          • D
            dan @david
            last edited by 13 Jul 2022, 11:00

            @david Thanks so much for doing this!

            --
            FusionAuth - Auth for devs, built by devs.
            https://fusionauth.io

            1 Reply Last reply Reply Quote 0
            • V vinicius.campitelli has marked this topic as solved on 30 May 2023, 18:37
            • P
              popupgeorgiahms4
              last edited by 13 Sept 2024, 01:02

              @david said in Why doesn't the example flutter demo code from github work on Android?:

              Hi all,

              I've been following the tutorial for using FusionAuth in a flutter app here: https://fusionauth.io/blog/2020/11/23/securing-flutter-oauth

              Using this code works perfectly in iOS, but doesn't work on my Android device (Google Pixel 6, Firefox browser).

              So I tried downloading the sample project from https://github.com/FusionAuth/fusionauth-example-flutter-dart/, and substituting my own values for the FusionAuth domain, etc. Again, this works perfectly in iOS, but on Android I never get redirected back to the app.

              There is some information here https://fusionauth.io/community/forum/topic/602/error-fusionauth-s-login-page-redirecting-issue-on-android/5 about creating an interstitial web page to complete the redirect to the app for Android devices. Is this really required? Or is there some step I'm missing here that will make this work for an Android app directly without needing to set up a special web page?

              Thanks,

              David

              Hi David,

              It sounds like you're dealing with a tricky issue with OAuth redirects on Android. Here are a few things you might consider:

              Custom URL Scheme and Deep Links: Make sure your Flutter app is properly configured to handle custom URL schemes and deep links on Android. This setup is crucial for redirecting back to the app after authentication. Check your AndroidManifest.xml file to ensure it has the correct intent filters for handling your OAuth callback URL.

              Browser Configuration: Sometimes, browser settings or extensions can interfere with OAuth redirects. Try testing with different browsers or clearing the browser cache and cookies on your Google Pixel 6.

              Redirect URI Handling: Verify that the redirect URI configured in FusionAuth matches exactly with the one used in your app. Any mismatch can cause issues with the redirect process.

              Interstitial Web Page: The information you found about creating an interstitial web page is a workaround that some developers use to handle OAuth redirects on Android. This page can help bridge the gap between the authentication provider and the app. However, it should not be necessary if the redirect is properly configured.

              Logs and Debugging: Enable logging and check the logs for any errors or issues related to the OAuth flow. This can provide valuable insights into where the process might be failing.

              If you’re still having trouble, you might want to consult the FusionAuth documentation or their community forum for additional support.

              Good luck, and I hope you get this resolved soon!

              1 Reply Last reply Reply Quote 0
              • First post
                Last post