Skip to content Skip to sidebar Skip to footer

How To Correctly Set Redirect_uri In Flutter App?

I'm trying to log the user into a Google API from my Flutter app, but can't get it to automatically fetch the token. The closest I got was to see the token string in the auth scree

Solution 1:

Have you tried adding :// to the end of your Scheme? I'm not sure you are providing a valid scheme name to Google.

Can you try ai.autonet.afterme:// or ai.autonet.afterme://auth?

Solution 2:

The correct way to set redirect_uri in flutter for both iOS and android is as follows:

  1. Step one Android - under android/app/build.gradle

    defaultConfig {
     applicationId "com.testingapp"// Set the applicationId
     minSdkVersion 18
     targetSdkVersion 30
     versionCode flutterVersionCode.toInteger()
     versionName flutterVersionNamemanifestPlaceholders= [
             'appAuthRedirectScheme': 'com.testingapp'// Add this also using your application ID URI as the based for all your derived URi
     ]
    }
    

iOS - ios/Runner/Info.plist

<dict><key>CFBundleURLTypes</key><array><dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLSchemes</key><array><string>com.testingapp</string> //Again Application Id should be added here
         </array></dict></array>

...

Then in your app you can use it as follows:

const AUTH0_REDIRECT_URI = "com.testingapp://login-callback";

please note the "://login-callback" is added to the application ID here, its not defined anywhere else.

Finally in your provider add it as well. In my case I am using keycloak.

enter image description here

Post a Comment for "How To Correctly Set Redirect_uri In Flutter App?"