CodetrixStudio / CapacitorGoogleAuth

Capacitor plugin for Google Auth. Lightweight & no dependencies.
MIT License
282 stars 154 forks source link

BUG: Signing in on iOS #90

Open luca-bruegger opened 3 years ago

luca-bruegger commented 3 years ago

Description

Hello together I am facing an Issue regarding the use of your plugin in Capacitor. Everything works fine, just until I want to Sign in with your google Plugin. It triggers an Error that I pasted below.

The App is configured, the way you got it described in your readme. At the moment, I have no clue what I am doing wrong.

Thanks for your help, regarding my problem.

Error

⚡️  [error] - ERROR Error: Uncaught (in promise): TypeError: null is not an object (evaluating 'gapi.auth2.getAuthInstance().grantOfflineAccess')

Code

import '@codetrix-studio/capacitor-google-auth';
import { Plugins } from '@capacitor/core';

export class AuthService {
  constructor(private firebaseAuth: AngularFireAuth,
              private firebaseFire: AngularFirestore) {  }

  async signInWithGoogleCordova() {
    const googleUser = await Plugins.GoogleAuth.signIn();
    const credential = firebase.auth.GoogleAuthProvider.credential(googleUser.authentication.idToken);
    return this.firebaseAuth.signInAndRetrieveDataWithCredential(credential);
  }
}
{
  "appId": "xxxxxxx",
  "appName": "xxxxxxx",
  "webDir": "www",
  "npmClient": "npm",
  "cordova": {
    "preferences": {
      "ScrollEnabled": "false",
      "android-minSdkVersion": "19",
      "BackupWebStorage": "none",
      "SplashMaintainAspectRatio": "true",
      "SplashShowOnlyFirstTime": "false",
      "SplashScreen": "screen"
    }
  },
  "plugins": {
    "GoogleAuth": {
      "scopes": [
        "profile",
        "email"
      ],
      "serverClientId": "xxxxxxx.apps.googleusercontent.com",
      "forceCodeForRefreshToken": true
    }
  }
}

xxxxxxxx -> placeholders, filled with real values in my project.
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>xxxxx</title>

    <base href="/" />

    <meta name="color-scheme" content="light dark" />
    <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="msapplication-tap-highlight" content="no" />
    <meta name="google-signin-client_id" content="xxxxxx.apps.googleusercontent.com">

    <!-- add to homescreen for ios -->
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  </head>

  <body>
    <app-root></app-root>
  </body>
</html>

Yes, I've done the iOS configuration and added the needed URL scheme in Xcode.

kaimallie commented 3 years ago

Same issue.

cyril-colin commented 3 years ago

I have a similar problem : google auth api was not downloaded automatically after plugin installation. So I added this line in rootPath/ios/App/Podfile : pod 'CodetrixStudioCapacitorGoogleAuth', :path => '../../node_modules/@codetrix-studio/capacitor-google-auth'

Now I am facing a new issue "Your app is missing support for the following URL schemes:"

Good luck !