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

Response not returned to calling javascript on Android #271

Open
nisegami opened this issue Aug 19, 2024 · 1 comment
Open

Response not returned to calling javascript on Android #271

nisegami opened this issue Aug 19, 2024 · 1 comment

Comments

@nisegami
Copy link

nisegami commented Aug 19, 2024

Description

Trying to use Google OAuth on Web+Android. Works fine in SPA. On Android, I see that the token is obtained successfully in the logs, but it is not returned to javascript successfully.

Capacitor version:

Output of npx cap doctor:

Latest Dependencies:       

  @capacitor/cli: 6.1.2    
  @capacitor/core: 6.1.2   
  @capacitor/android: 6.1.2

Installed Dependencies:    

  @capacitor/cli: 6.1.2    
  @capacitor/core: 6.1.2   
  @capacitor/android: 6.1.2

[success] Android looking great! 👌

Library version:

Using version 6.1.0 of the library.

OAuth Provider:

  • Google

Your Plugin Configuration

{
        authorizationBaseUrl: 'https://accounts.google.com/o/oauth2/auth',
        accessTokenEndpoint: 'https://www.googleapis.com/oauth2/v4/token',
        scope: 'email profile',
        resourceUrl: 'https://www.googleapis.com/userinfo/v2/me',
        logsEnabled: false,
        web: {
            appId: config.public.googleWebClientId,
            accessTokenEndpoint: '',
            responseType: 'token',
            windowTarget: '_self',
            redirectUrl: `${config.public.appURL}/${action}/google`,
        },
        android: {
            appId: config.public.googleAndroidClientId,
            redirectUrl: `${config.public.androidPackageId}:/`,
            responseType: 'code',
            pkceEnabled: true,
        }
    }

Affected Platform(s):

  • Android
    • Version/API Level:
    • Device Model:
    • Content of your AndroidManifest.xml
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <!-- Permissions -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-feature android:name="android.hardware.location.gps" android:required="false" />

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    <uses-feature android:name="android.hardware.camera" android:required="false" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="false"
        android:requestLegacyExternalStorage="true"
        android:theme="@style/AppTheme">
        <activity
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
            android:name=".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>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="@string/custom_url_scheme" android:host="app" />
            </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" />
        </provider>
    </application>
</manifest>
@marcoelio
Copy link

I have the same problem. I have searched and searched, I have tried many possible options, but I have not been able to solve the problem.
Any solution please.

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

No branches or pull requests

2 participants