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

Google with android says "Custom scheme URIs are not allowed for 'WEB' client type" #242

Open
matonga opened this issue Nov 24, 2023 · 3 comments
Labels

Comments

@matonga
Copy link

matonga commented Nov 24, 2023

Description

Can't get Google to login with android. It says:

Custom scheme URIs are not allowed for 'WEB' client type.

I'm puzzled by this error because I thought the plugin used some native android library to do the login on android. I must have misconfigured something, at least because many people have succesfully used this plugin before, but I can't figure out what I'm doing wrong.

Capacitor version:

Capacitor 5.0.3

Run npx cap doctor:

💊   Capacitor Doctor  💊 

Latest Dependencies:

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

Installed Dependencies:

  @capacitor/ios: not installed
  @capacitor/cli: 5.0.3
  @capacitor/core: 5.0.3
  @capacitor/android: 5.0.3

[error] Missing <manifest package=""> attribute in app/src/main

After adding package (removed it on update to capacitor 5, so I dunno what's going on with doctor):

[error] MainActivity .MainActivity is not in manifest package com.visionblo.apps.movilidadandina.
        Please update the packages to be the same.

After replacing .MainActivity with com.visionblo.apps.movilidadandina.MainActivity:

[success] Android looking great! 👌

Library version:

  • other: 5.0.0

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: true,
    android: {
        responseType: 'code',
        redirectUrl: 'com.visionblo.apps.movilidadandina:/',
        appId: _(redacted)_
    }
}

Affected Platform(s):

  • Android
    • Version/API Level: 11/30
    • Device Model: moto g200 5G
    • Content of your AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.visionblo.apps.movilidadandina">
    <!-- 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-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <!-- el plugin exige WRITE_EXTERNAL_STORAGE, aún cuando no lo necesito... hijos de p... -->
    <uses-feature android:name="android.hardware.location.gps" />
    <!-- el uses-feature asegura que no puedas instalar la app en un celular sin GPS (lo cual no tendría sentido para esta app) -->

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

        <activity
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
            android:name="com.visionblo.apps.movilidadandina.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>

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

        <service
            android:name="com.visionblo.apps.movilidadandina.LocationService"
            android:enabled="true"
            android:foregroundServiceType="location"
            android:exported="false"
        />
        <!-- si lo implemento con "geocercas" tal vez no haga falta usar android:foregroundServiceType="location" y familia -->
        <!-- ok hasta ahora no hizo falta pero se lo agrego por las dudas -->
        <!-- [2023-10-28] lo de "geocercas" estuvo bueno pero la precisión era fatalmente mala, vamos con el servicio nomás -->

        <!-- service
            android:name="com.visionblo.apps.movilidadandina.ReportService"
            android:enabled="true"
            android:foregroundServiceType="dataSync"
            android:exported="false"
        / -->
            <!-- android:permission="android.permission.BIND_JOB_SERVICE" -->

        <receiver android:name="com.visionblo.apps.movilidadandina.IntentReceiver" android:enabled="true" android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
            </intent-filter>
        </receiver>

    </application>
</manifest>
@matonga
Copy link
Author

matonga commented Nov 24, 2023

Updated capacitor to meet last dependencies:

npx cap doctor output:

💊   Capacitor Doctor  💊 

Latest Dependencies:

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

Installed Dependencies:

  @capacitor/ios: not installed
  @capacitor/core: 5.5.1
  @capacitor/android: 5.5.1
  @capacitor/cli: 5.5.1

[success] Android looking great! 👌

Did npx cap sync after that. Just in case. But I'm still getting the error message.

@matonga
Copy link
Author

matonga commented Nov 25, 2023

I also tried with Azure Portal, and... it works great, I can even validate the id_token afterwards in a server:

{
	appId: _(redacted)_,
	authorizationBaseUrl: 'https://login.microsoftonline.com/_(redacted)_/oauth2/v2.0/authorize',
	scope: "openid email",
	accessTokenEndpoint: 'https://login.microsoftonline.com/_(redacted)_/oauth2/v2.0/token',
	resourceUrl: "https://graph.microsoft.com/v1.0/me/",
	responseType: "code",
	pkceEnabled: true,
	logsEnabled: true,
	android: {
		redirectUrl: 'com.visionblo.apps.movilidadandina://oauth/redirect'
	}
}

I don't understand what am I doing wrong with Google. Anyways, I was using Google as a test, the final version was meant to authenticate against an Azure Portal. Should I close this ticket or leave it open?

@moberwasserlechner
Copy link
Collaborator

Thx for the information. I have a upcoming release myself and will try it myself.

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

2 participants