capacitor-community / generic-oauth2

Generic Capacitor OAuth 2 client plugin. Stop the war in Ukraine!
MIT License
223 stars 106 forks source link

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

Open matonga opened 7 months ago

matonga commented 7 months ago

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:

OAuth Provider:

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

matonga commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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