Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Intent filter not working for redirection after login #231

Open
MGX-CODING opened this issue Mar 8, 2023 · 2 comments
Open

Bug: Intent filter not working for redirection after login #231

MGX-CODING opened this issue Mar 8, 2023 · 2 comments
Labels

Comments

@MGX-CODING
Copy link

MGX-CODING commented Mar 8, 2023

Capacitor version:

Run npx cap doctor:

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 4.7.0
  @capacitor/core: 4.7.0
  @capacitor/android: 4.7.0
  @capacitor/ios: 4.7.0

Installed Dependencies:

  @capacitor/cli: 4.6.3
  @capacitor/core: 4.6.3
  @capacitor/android: 4.6.3
  @capacitor/ios: 4.6.3

[success] Android looking great! 👌

Library version:

    "@byteowls/capacitor-oauth2": "^4.0.0",

OAuth Provider:

I would say none ?
I would assume my company uses some custom implementation, but something I can tell you for sure is that Oauth2/OIDC work perfectly on the web with the library angular-oauth2-oidc, if that can help

Your Plugin Configuration

    OAuth2Client.authenticate({
      authorizationBaseUrl: 'https://mycompanyurl/openam/oauth2/preprod/authorize',
      redirectUrl: location.origin,
      responseType: 'code',
      pkceEnabled: true,
      appId: 'myappclientid,
      scope: 'my scope',
    }).then(res => {
      console.log('RESPONSE');
      console.log(res);
    });

Affected Platform(s):

  • Android
    • Version/API Level: Android 13, API level, SDK Version 32
    • Device Model: Pixel 7 Pro
    • Content of your AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="myPackageName">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:networkSecurityConfig="@xml/network_security_config">

        <activity
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
            android:name="myPackageName.MainActivity"
            android:label="@string/title_activity_main"
            android:theme="@style/AppTheme.NoActionBarLaunch"
            android:launchMode="singleTask"
            android:exported="true">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <intent-filter>
              <data android:scheme="@string/custom_url_scheme" android:host="localhost" />
              <action android:name="android.intent.action.VIEW"/>
              <category android:name="android.intent.category.DEFAULT"/>
              <category android:name="android.intent.category.BROWSABLE"/>
            </intent-filter>

        </activity>

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths"></meta-data>
        </provider>
    </application>

    <!-- Permissions -->

    <uses-permission android:name="android.permission.INTERNET" />
</manifest>

Current Behavior

The redirection to the login form works great, I can input my credentials, but then, the redirect back to my application does not work.

I followed the Android guidelines for the library and I cannot pinpoint the issue I am facing.

I tried modifying the intent filter and the capacitor config a lot of times and nothing seems to work.

Please keep in mind, I'm a JS developer, my knowledge of Java / Android is limited !

Expected Behavior

Should work

Sample Code or Sample Application Repo

Sorry, no reproduction possible ...

Other Information

Capacitor config file : I have to edit the server scheme and host for CORS, and also for Oauth redirect URLs. Would that be the issue ?

import { CapacitorConfig } from '@capacitor/cli';

export default {
  bundledWebRuntime: false,
  server: {
    cleartext: true,
    androidScheme: 'http',
    hostname: 'localhost:4200',
  },
  plugins: {
    LocalNotifications: {
      smallIcon: 'ic_stat_icon_config_sample',
      iconColor: '#488AFF',
      sound: 'beep.wav',
    },
  },
  appId: 'MyAppId',
  appName: 'MyAppName',
  webDir: 'dist/pwa_MyAppName',
  android: {
    allowMixedContent: true,
    flavor: 'dev',
  },
  ios: {
    scheme: `MyAppName - dev`,
  },
} as CapacitorConfig;
@JacquesBeets
Copy link

Getting a similar issue on our side as well.

@di-appteam
Copy link

Any update, I am facing same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants