Earlybyte / aad_oauth

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

ERR_UNKNOWN_URL_SCHEME Error Appears After Successful Login #313

Closed aveyselbozoglu closed 3 weeks ago

aveyselbozoglu commented 3 months ago

In my pubspec.yaml i have, environment: sdk: ">=2.17.6 <3.13.7" , webview_flutter: ^3.0.4 , aad_oauth: ^0.4.1 versions , and in my code

 static final Config config = Config(
    tenant: 'c4****ce',
    clientId: '2c****a14',
    scope: 'openid profile offline_access',
    redirectUri: 'msauth://com.myapp.mobile/w******Hw%3D',
    navigatorKey: navigatorKey,

  );
  final AadOAuth oauth = AadOAuth(config);

   await oauth.login();
   await oauth.getAccessToken();
   String? token = await oauth.getIdToken();

after this line of code
await oauth.login(); i can login to Azure Ad and then this error appears just a little time then my login is successful.

WebPage not available the webpage at msauth://......... net : ERR_UNKNOWN_URL_SCHEME

Couldn't fix it , any help very appriciated.

Here is my also AndroidManifest.xml file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.myapp.mobile">
       <uses-permission android:name="android.permission.INTERNET" />

   <application
       android:icon="@mipmap/ic_launcher"
       android:label="Pho"
       android:usesCleartextTraffic="true">

        <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>

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <!-- msauth://{your_package_name} -->
                <data android:scheme="msauth"
                      android:host="com.myapp.mobile" />
            </intent-filter>

        </activity>

        <activity
            android:name="com.microsoft.identity.client.BrowserTabActivity">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="msauth"
                    android:host="com.myapp.mobile" 
                    android:path="/w****Hw=" /> 
            </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>

</manifest>
github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you still think this issue is needed, reopen it again.

github-actions[bot] commented 3 weeks ago

false