2

I'm developing a mobile application in Flutter/Dart and I'm currently working on identity management, specifically the login functionality. I'm using a library called flutter_appauth which is a wrapper for the AppAuth library. I'm having a strange issue that only happens on Android where after a user successfully logs in, no redirection occurs. If the user re-opens the login page after a successful login occurs, they're greeted by a blank screen in the WebView (presumably because the browser keeps the user logged in). The authentication flow for my application goes: App -> Login page -> Identity provider for 2FA -> App. This is what occurs on iOS yet does not redirect back from the ID provider on Android. The application stays on the completed authentication page. The identity provider I'm using is PingID.

This library handles redirection by allowing you to simply define the redirect scheme, which is just the prefix part of the redirect URI. I correctly defined the Redirection scheme in the app/build.gradle file as well as the redirection URI as the following:

Redirect URI: AppName:/callback

defaultConfig {
    applicationId "io.example.AppName"
    minSdkVersion 16
    targetSdkVersion 29
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    manifestPlaceholders = [
            'appAuthRedirectScheme': 'AppName'
    ]
}

I made an issue post on the plugin's GitHub which you can take a look at here. The author of the plugin states that if the scheme name and redirect URI are the same, then my issue lies elsewhere. Because my code works on iOS, and I used the same name for the redirect scheme for both platforms, I would imagine my issue isn't me incorrectly defining the redirection scheme. Everything works perfectly on an iOS emulator. I've tested it on 4 different Android devices and 4 different API versions and I have the same issue on all of them. I also tried defining an intent for RedirectUriReceiverActivity and my issue still persists.

I'm new to Flutter, Mobile Dev, and IdM so I would appreciate some guidance. Is there a difference between Chrome and Safari, or iOS and Android that could potentially be blocking this redirection from occurring? I've been searching the internet for a solution for the past 4 days and I have yet to find one so I'm pretty much all out of leads. Any advice?

EDIT: I finally got it working! Hopefully this will help out anyone in the future with this problem. It turns out all I had to do was set the scheme name for appAuthRedirectScheme to an entirely lower case string. So even though my Redirect URI is AppName:/callback, I had to set appAuthRedirectScheme to appname instead of AppName. This got it working.

2 Answers 2

2

After several hours of troubleshooting this is what solved my issue with Android and not iOS. It's good to know moving forward that the build.gradle is case-sensitive. Lesson learned.

manifestPlaceholders = [
        'appAuthRedirectScheme': 'appname'
]
1

I saw your GH issue report when it came in. I use AppAuth too. Before I incorporated into my own app, I fully tested the example app that comes with it:

https://github.com/MaikuB/flutter_appauth/tree/master/flutter_appauth/example

Have you substituted all the example variables etc. and confirmed that all works on iOS and Android?

Can back to basics and use the example app, if you still have an issue, you can add to the issue you've raised and compare the example with your own app.

In life, it's usually a typo or permissions :-)

Thanks.

4
  • Thank you for your response Gavin. I did try test running the example project and it successfully redirects back to the application on my laptop. However, when I filled in my own credentials (in main.dart and app/build.gradle), I still have this issue. I guess the issue could be on my company's server side, but I don't know what the issue is so I don't know what to ask or what I need to get changed. Any ideas on the differences between iOS and Android, or Chrome and Safari? I appreciate the help! Commented Jun 23, 2020 at 21:01
  • Glad you solved the issue and thanks for letting everyone know on the github issue. Commented Jun 24, 2020 at 17:41
  • Since you didn't follow up, the answer was to make everything lower case. So AppName should be appname. Commented Jun 25, 2020 at 18:02
  • 1
    Hey Gavin, I actually did follow up, I just edited my original post instead of making a new comment. Still new to posting on StackOverflow so I wasn't sure which one was preferred. Thanks for the help though! Commented Jun 26, 2020 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.