Earlybyte / aad_oauth

Flutter Azure Active Directory OAuth Package
https://pub.dev/packages/aad_oauth
MIT License
93 stars 190 forks source link

App not redirected after authentication from microsoft. #346

Open Deepakraj2022 opened 1 month ago

Deepakraj2022 commented 1 month ago

Hi I am trying to login with microsoft login. Once the login is success, then it is not redirected to App.

Media Below is my androidManifext file ` <application android:label="newlogin" android:name="${applicationName}" android:icon="@mipmap/ic_launcher"> <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">

        <meta-data
          android:name="io.flutter.embedding.android.NormalTheme"
          android:resource="@style/NormalTheme"
          />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>

    </activity>
   <activity
        android:name="com.linusu.flutter_web_auth.CallbackActivity"
        android:exported="true"
        android:launchMode="singleTask">
        <intent-filter android:label="auth">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:scheme="com.example.newlogin"
                android:host="MG2SCfaXfIy27F04sIf6U9gahV8="
               />
        </intent-filter>
    </activity>
    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>
<!-- Required to query activities that can process text, see:
     https://developer.android.com/training/package-visibility?hl=en and
     https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.

     In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
    <intent>
        <action android:name="android.intent.action.PROCESS_TEXT"/>
        <data android:mimeType="text/plain"/>
    </intent>
</queries>

`

below is my configuration in azure portal image

image

Can anyone help me what mistake I made

justoke commented 1 month ago

I use the Azure B2C platform and have an app registration similar to yours. I would suggest you use the returnURL defined in your app registration as shown below: image

The return URL should be accessible, I don't see how the login server which is public can redirect to a scheme defined on your host device. I'd remove that from your app registration and check the boxes on the two defined return URLS. From the Overview section of the app registration you can get all the settings you need. Here is a screenshot of my setup for the aad_oauth: image

Deepakraj2022 commented 3 weeks ago

I tried with RedirectUri: "https://deepakshipnet.b2clogin.com/oauth2/nativeclient", Login is successfully done but page is not redirected to App. I tried setting config.webUseRedirect to both true and false. image

result.fold( (l) => showError(l.toString()), (r) => showMessage('Logged in successfully, your access token: $r'), ); are not executed.