Skip to content

Response not returned to calling javascript on AndroidΒ #271

@nisegami

Description

@nisegami

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions