GithubHelp home page GithubHelp logo

codetrixstudio / capacitorgoogleauth Goto Github PK

View Code? Open in Web Editor NEW
255.0 255.0 139.0 924 KB

Capacitor plugin for Google Auth. Lightweight & no dependencies.

License: MIT License

Ruby 2.45% Java 22.15% Objective-C 1.04% Swift 14.24% JavaScript 3.48% TypeScript 35.72% HTML 3.28% SCSS 17.65%
android authentication capacitor capacitor-plugin google ios pwa web

capacitorgoogleauth's People

Contributors

adamschoenemann avatar aerodynamics-digital avatar caolancode avatar ctrengove avatar dependabot[bot] avatar endrzei avatar fullstackduck avatar ghonche avatar hoi4 avatar itslucario avatar joeflateau avatar kerimm avatar lambirou avatar leo6104 avatar luca-peruzzo avatar macdja38 avatar martin-eckleben avatar mirko77 avatar monomachus avatar nlueg avatar piotr-cz avatar pszalanski avatar razmans avatar reslear avatar riderx avatar sawaca96 avatar spaghiajoeojo avatar teaqu avatar th3brink avatar yuripetusko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

capacitorgoogleauth's Issues

'NSInvalidArgumentException', reason: 'You must specify |clientID| for |GIDSignIn|' on iOS

GoogleAuth works on web, but iOS does not work.

I got uncaught exception when I click the login button of Google.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'You must specify |clientID| for |GIDSignIn|'

I added REVERSED_CLIENT_ID as url scheme to Info.plist from GoogleService-Info.plist

スクリーンショット 2019-11-24 20 41 39

capacitor.config.json is like below.

{
  "appId": "com.my.app",
  "appName": "appName",
  "bundledWebRuntime": false,
  "npmClient": "npm",
  "webDir": "www",
  "plugins": {
    "GoogleAuth": {
      "scopes": [
        "profile",
        "email"
      ],
      "serverClientId": "xxxxx.apps.googleusercontent.com"
    }
  }
}

serverClientId is from OAuth 2.0 Client Id of web in Google Cloud Platform

Do you have any idea what am I worng?

Handling different serverClientId values

I have multiple projects in Firebase each with a different client id. This is to handle different environments. e.g. staging, dev, production.

How would you pass the different client Id values to the capacitor.config.json file?

  "plugins": {
    "GoogleAuth": {
      "scopes": ["profile","email"],
      "serverClientId": "XXXXXX.apps.googleusercontent.com"
    }
  }

Cannot retreive access_token.

Hi @parveenkhtkr ,

Could you please give me a hint how to obtain access_token?
I've tried with "scopes": ["profile", "email", "openid"], and "scopes": ["profile", "email"] but without luck.
I am getting only idToken which is not really useful for me when I'm trying to combine solution with firebase and my external IdP. If it is not possible in this plugin, then please let us know.

Thank you,
Piotr

CORS issue

Hi,
Trying to use it but no way to make it work.

Uncaught (in promise) TypeError: Cannot read property 'content' of undefined
    at HTMLScriptElement.<anonymous> (web.js:55)
    at Generator.next (<anonymous>)
    at web.js:25
    at new Promise (<anonymous>)
    at push../node_modules/@codetrix-studio/capacitor-google-auth/dist/esm/web.js.__awaiter (web.js:2)
    at web.js:53
    at platform.js:23
    at jb (platform.js:15)
    at ea (platform.js:23)
    at Array.Qb.F.<computed> (platform.js:23)
    at Object.Qb.I.<computed> (platform.js:23)
    at cb=gapi.loaded_0:1
(anonymous) @ web.js:55
(anonymous) @ web.js:25
push../node_modules/@codetrix-studio/capacitor-google-auth/dist/esm/web.js.__awaiter @ web.js:2
(anonymous) @ web.js:53
(anonymous) @ platform.js:23
jb @ platform.js:15
ea @ platform.js:23
Qb.F.<computed> @ platform.js:23
Qb.I.<computed> @ platform.js:23
(anonymous) @ cb=gapi.loaded_0:1
login:1 Access to fetch at 'https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en_GB.rInhnj3_a4A.O/m=auth2/rt=j/sv=1/d=1/ed=1/am=wQE/rs=AGLTcCOQYHmIc15BT4w5yyr6ria9uV-nGA/cb=gapi.loaded_0' from origin 'http://localhost:8100' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Low-level support in Capacitor

Hello!

Just curious, would it be helpful to this plugin if Capacitor would support SFAuthenticationSession and Chrome Custom Tabs, as a part of their Browser API?

I'm thinking those two would be good additions to the Capacitor Browser API.

Problem with authentication since Angular10

Hi there,

i´ve the following error since i updated to Angular10:

Property 'authentication' does not exist on type '{ value: string; }'

I used the workaround with "null" on signIn method.

Here is my code:

let googleUser = await Plugins.GoogleAuth.signIn(null);
const credential = auth.GoogleAuthProvider.credential(googleUser.authentication.idToken);
return this.afAuth.auth.signInAndRetrieveDataWithCredential(credential);

SignIn error and Logout is not found

All working fine, but some weeks ago I find SignIn which accept 1 parameter (now I've put null) but it gives me error, then logout isn't available.

Help, please!

Request server auth code on android

The following code in the init method is required to request the serverAuthCode on android

        .requestServerAuthCode(serverClientId)

it can be chained into the builder like so

                .requestIdToken(clientId)
                .requestServerAuthCode(clientId)
                .requestEmail();

Required to reach feature parody with #5 on iOS.

You must specify |clientID| for |GIDSignIn in IOS

I follow the steps:

  1. Make sure you have GoogleService-Info.plist with CLIENT_ID
  2. Add REVERSED_CLIENT_ID as url scheme to Info.plist

But in IOS doesn't work and the show this error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'You must specify |clientID| for |GIDSignIn|'

Imgur

That is the locations for GoogleService-Info.plist and Info.plist

Imgur

My GoogleService-Info.plist have the CLIENT_ID and REVERSED_CLIENT_ID

Imgur

My Info.plist have the `REVERSED_CLIENT_ID as an url scheme:

Imgur

My capacitor.config.json:

Imgur

I did check #30 but doesn't work

My environment:

@capacitor/cli 2.0.1
@capacitor/android 2.0.1
@capacitor/ios 2.0.1
@capacitor/core 2.0.1

 Found 3 Capacitor plugins for ios:
    @codetrix-studio/capacitor-google-auth (2.0.1)
    @rdlabo/capacitor-facebook-login (2.0.2)
    capacitor-apple-login (0.0.6)

Is it possible to send state?

We need to send a value into the authorization queryString and have google send that back to use with the redirect URI. Usually this is done using state key. Is it possible to send state using this plugin? I couldn't find any documentation regarding the same?

Primarily we need this for web.

Callback on any token update

It would be great to have a callback whenever there is a token update (at startup and later) in order to save the updated token to the application store :-)

Cannot retrieve access_token (updated)

Hi, when I use web, the answer comes in the format:
{ id: string; email: string; name: string; familyName: string; givenName: string; imageUrl: string; serverAuthCode: string; authentication: { accessToken: string; idToken: string; }; }

and I can get accessToken, but when I use this implementation on android, the answer comes in a different format:
{ id: string; email: string; name: string; familyName: string; givenName: string; imageUrl: string; idToken: string; serverAuthCode: string; authentication: { idToken: string; }; }
we get idToken 2 times and there is no accessToken field.
How do I get accessToken? Maybe there is another way

Thank you,
Alexandr

Originally posted by @Alexandr-Pivovar in #32 (comment)

'error: cannot find symbol class GoogleAuth'

Apologies if im missing something obvious here but when i try to build android i get the error error: cannot find symbol class GoogleAuth, i have changed my MainActivity.java file to the following

    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      add(GoogleAuth.class);
    }});

Perhaps i need to import something?

[Android] Google Sign In webview does not redirect back to app

Hi,

I'm trying to add Google authentication to my Capacitor app. I followed the tutorial on the repo, the Google Sign In webview is being opened, however upon successful login, it switches to "One moment please..." and it never closes the webview or goes back to the app.

The android:launchMode in my manifest is currently set to "singleTask", and I tried "singleInstance" as well.

When tested on web, the authentication worked properly (popup window was closed and I got the accessToken back).

Would appreciate help in trying to solve this. Thanks!

CapacitorGoogleAuth 2.1.1 iOS [Plugin.swift] build issue

Edit: Updated build to the latest version still unable to build

Edit 6/25/2020: Updated build version to 2.1.1 the issue is still prominent in build

Not sure if this would be a duplicate of issue #49 but after updating my dependancies and attempting to build to emulator and device I have hit 6 issues with Plugin.swift

~/.../node_modules/@codetrix-studio/capacitor-google-auth/ios/Plugin/Plugin.swift:21:22: Value of type 'GIDSignIn' has no member 'presentingViewController' on line 21

~/.../node_modules/@codetrix-studio/capacitor-google-auth/ios/Plugin/Plugin.swift:39:34: Value of type 'GIDSignIn' has no member 'hasPreviousSignIn' on line 39

~/.../node_modules/@codetrix-studio/capacitor-google-auth/ios/Plugin/Plugin.swift:40:35: Value of type 'GIDSignIn' has no member 'restorePreviousSignIn' on line 40

Now this started happening after I ran npm install; npx cap sync

Attached are the issues from Plugin.swift
image

image

Here is the package.json for the capacitor project:

"private": true,
  "dependencies": {
    "@angular/animations": "^9.1.11",
    "@angular/cdk": "^8.1.2",
    "@angular/common": "~9.1.11",
    "@angular/core": "~9.1.11",
    "@angular/flex-layout": "^10.0.0-beta.32",
    "@angular/forms": "^9.1.11",
    "@angular/material": "^8.1.2",
    "@angular/platform-browser": "~9.1.11",
    "@angular/platform-browser-dynamic": "~9.1.11",
    "@angular/router": "~9.1.11",
    "@capacitor/android": "^1.2.1",
    "@capacitor/cli": "^1.5.2",
    "@capacitor/core": "2.0.0-beta.1",
    "@capacitor/ios": "^1.2.1",
    "@codetrix-studio/capacitor-google-auth": "2.1.1",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/firebase": "^5.25.0",
    "@ionic-native/in-app-purchase": "^5.15.1",
    "@ionic/angular": "^4.11.3",
    "@ionic/storage": "^2.2.0",
    "@ngxs/store": "^3.5.1",
    "@rdlabo/capacitor-facebook-login": "^1.1.2",
    "@reative/angular": "^1.7.0",
    "@reative/cache": "^1.3.1",
    "@reative/core": "^4.0.2",
    "@reative/firebase": "^1.7.0",
    "@reative/records": "^1.3.1",
    "@reative/state": "^1.3.1",
    "@swimlane/ngx-charts": "^12.0.1",
    "@webcomponents/webcomponentsjs": "^2.2.10",
    "animate.css": "^3.7.2",
    "axios": "^0.19.0",
    "capacitor-fcm": "^0.1.0",
    "cordova-plugin-inapppurchase": "^1.2.0",
    "cordova-plugin-purchase": "git+https://github.com/j3k0/cordova-plugin-purchase.git",
    "core-js": "^2.5.4",
    "firebase": "^7.15.4",
    "font-awesome": "^4.7.0",
    "gsap": "^2.1.3",
    "hammerjs": "^2.0.8",
    "leader-line": "^1.0.5",
    "moment-range": "^4.0.2",
    "moment-timezone": "^0.5.26",
    "ng2-validation": "^4.2.0",
    "ngx-moment": "^3.4.0",
    "plain-draggable": "^2.5.12",
    "rxjs": "~6.5.5",
    "tslib": "^1.13.0",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/architect": "~0.801.2",
    "@angular-devkit/build-angular": "^0.803.25",
    "@angular-devkit/core": "~8.1.2",
    "@angular-devkit/schematics": "~8.1.2",
    "@angular/cli": "^9.1.6",
    "@angular/common": "^9.1.11",
    "@angular/compiler": "~9.1.11",
    "@angular/compiler-cli": "~9.1.11",
    "@angular/core": "^9.1.11",
    "@angular/language-service": "~9.1.11",
    "@ionic/angular": "^4.11.10",
    "@ionic/angular-toolkit": "~2.0.0",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.0.0",
    "install-peers": "^1.0.3",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^5.0.5",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "^7.0.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.8.3"
  },
  "description": "An Ionic project",
  "prettier": {
    "printWidth": 140,
    "singleQuote": true,
    "jsxBracketSameLine": false,
    "disableLanguages": [
      "html"
    ]
  },

Google SignIn Error 12500

Something has changed over the past 2-3 days that's now causing this problem. Last week this was working fine for me. I've updated to version 2.0.1 (though I was already on version 2.0.0) but to no avail.

Screenshot 2020-04-13 at 2 59 47 PM

Bug : Ionic + React

Hi im getting this error when try to implement your plugin
this is after select the google account to sign in

2020-05-22 22:26:53.820 25970-25970/com.timugo.pets E/Capacitor/Plugin: Something went wrong
    com.google.android.gms.common.api.ApiException: 12500: 
        at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(com.google.android.gms:play-services-base@@17.1.0:4)
        at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(com.google.android.gms:play-services-auth@@18.0.0:9)
        at com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.handleOnActivityResult(GoogleAuth.java:70)
        at com.getcapacitor.Bridge.onActivityResult(Bridge.java:770)
        at com.getcapacitor.BridgeActivity.onActivityResult(BridgeActivity.java:212)
        at android.app.Activity.dispatchActivityResult(Unknown Source:11)
        at android.app.ActivityThread.deliverResults(Unknown Source:44)
        at android.app.ActivityThread.handleSendResult(Unknown Source:160)
        at android.app.servertransaction.ActivityResultItem.execute(Unknown Source:11)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(Unknown Source:99)
        at android.app.servertransaction.TransactionExecutor.execute(Unknown Source:34)
        at android.app.ActivityThread$H.handleMessage(Unknown Source:36)
        at android.os.Handler.dispatchMessage(Unknown Source:21)
        at android.os.Looper.loop(Unknown Source:207)
        at android.app.ActivityThread.main(Unknown Source:107)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
        at com.android.internal.os.ZygoteInit.main(Unknown Source:274)
2020-05-22 22:26:53.825 25970-25970/com.timugo.pets D/Capacitor: Sending plugin error: {"save":false,"callbackId":"106465218","pluginId":"GoogleAuth","methodName":"signIn","success":false,"error":{"message":"Something went wrong"}}

Allow google cloud credentials

Currently the plugin is dependent on credentials from https://firebase.google.com/ and won't work with just credentials from https://console.cloud.google.com/

On Android, this is due to the googleSignInBuilder having this two methods

.requestIdToken(clientId)
.requestServerAuthCode(clientId, forceCodeForRefreshToken)

While on iOS the googleSignIn property is requiring the GoogleService-Info.plist and retrieving the clientID from that file.
And it's also assigning a value to googleSignIn.serverClientID which is not needed when just using the google cloud client id

A simple if statement and a capacitor.config.json option on which credentials to use would solve this

iOS Build Fails With Errors

After adding @codetrix-studio/capacitor-google-auth plugin, the iOS build now fails with the errors:

Plugin.swift:110:23: Use of undeclared type 'GIDSignInUIDelegate'
Screenshot 2019-08-29 15 50 55

Plugin.swift:21:9: Value of type 'GIDSignIn' has no member 'uiDelegate'; did you mean 'delegate'?
Screenshot 2019-08-29 15 49 25

Plugin.swift:39:21: Value of type 'GIDSignIn' has no member 'hasAuthInKeychain'
Plugin.swift:40:22: Value of type 'GIDSignIn' has no member 'signInSilently'
Screenshot 2019-08-29 15 50 00

Plugin.swift:73:53: Extra argument 'sourceApplication' in call
Screenshot 2019-08-29 15 50 25

Android Error: {"message":"Something went wrong"}

Condition:
Pop up selection for google account appeared.
Returning from pop up selection, error.

Device:

  • Android 7.0

On application load:
E/Capacitor/Plugin/Console: Unhandled Promise rejection: Cannot read property 'content' of undefined ; Zone: <root> ; Task: null ; Value: {} TypeError: Cannot read property 'content' of undefined at HTMLScriptElement.<anonymous> (http://localhost/google-sign-in-google-sign-in-module.js:79:84) at Generator.next (<anonymous>) at http://localhost/google-sign-in-google-sign-in-module.js:52:71 at new ZoneAwarePromise (http://localhost/polyfills.js:3272:29) at push../node_modules/@codetrix-studio/capacitor-google-auth/dist/esm/web.js.__awaiter (http://localhost/google-sign-in-google-sign-in-module.js:48:12) at gapi.load (http://localhost/google-sign-in-google-sign-in-module.js:77:34) at https://apis.google.com/js/platform.js:18:214 at Sa (https://apis.google.com/js/platform.js:10:467) at Y (https://apis.google.com/js/platform.js:18:197) at Array.E.(anonymous function) (https://apis.google.com/js/platform.js:18:297)

On google signing in:
E/Capacitor/Plugin: Something went wrong com.google.android.gms.common.api.ApiException: 10: at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source) at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source) at com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.handleOnActivityResult(GoogleAuth.java:62) at com.getcapacitor.Bridge.onActivityResult(Bridge.java:720) at com.getcapacitor.BridgeActivity.onActivityResult(BridgeActivity.java:209) at android.app.Activity.dispatchActivityResult(Activity.java:6919) at android.app.ActivityThread.deliverResults(ActivityThread.java:4226) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4273) at android.app.ActivityThread.-wrap20(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1597) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:203) at android.app.ActivityThread.main(ActivityThread.java:6324) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1085) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:946) E/Capacitor/Plugin/Console: ERROR Error: Uncaught (in promise): Object: {"message":"Something went wrong"}

How to get basic profile or email?

Try with ionic, build for native ios.
Successfully sign-in, the return value didn't contain any user information.

Anyhow to retrieve it?

Error while using the plugin in iOS

First of all thank you for the useful plugin!

In the browser, my implementation works well. In iOS not - the following error is shown on sign in:

Bildschirmfoto 2019-10-20 um 00 31 02

And here the named code line:

Bildschirmfoto 2019-10-20 um 00 37 10

Ability to force email selection to get refreshtoken

I need to get a refreshtoken eachtime I use googleAuth, and I prefer that the plugin show me the email selection prompt eachtime.
I've edited your plugin to force it, by replacing googleSignInBuilder.requestServerAuthCode(clientId) with .requestServerAuthCode(clientId,true)
https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInOptions.Builder#requestServerAuthCode(java.lang.String,%20boolean)

Maybe you should set it to true by default, or add a parameter into capacitor config.
I haven't done a PR because I don't know if it is the same way for iOS.

Thank you for this great plugin

Get code for server side use

In the iOS flow it would be nice to be able to get a one time code to send to the server so it can take action on behalf of the user. It shouldn't be more than a couple lines of additional code from what I can see here and would greatly increase the usability of this library, at least in my case.

Getting Google API Exception: 10

Followed the instructions, but am getting this error on calling Plugins.GoogleAuth.signIn():

V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 39112375, pluginId: GoogleAuth, methodName: signIn
V/Capacitor: callback: 39112375, pluginId: GoogleAuth, methodName: signIn, methodData: {}
D/Capacitor: Starting activity for result
I/Timeline: Timeline: Activity_launch_request time:4659556 intent:Intent { act=com.google.android.gms.auth.GOOGLE_SIGN_IN pkg=v.lucidfrontier cmp=v.lucidfrontier/com.google.android.gms.auth.api.signin.internal.SignInHubActivity (has extras) }
D/Capacitor: App paused
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@2c88202
I/Timeline: Timeline: Activity_launch_request time:4659584 intent:Intent { act=com.google.android.gms.auth.GOOGLE_SIGN_IN pkg=com.google.android.gms (has extras) }
E/Capacitor/Plugin: Something went wrong
    com.google.android.gms.common.api.ApiException: 10: 
        at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source:4)
        at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source:8)
        at com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.handleOnActivityResult(GoogleAuth.java:62)
        at com.getcapacitor.Bridge.onActivityResult(Bridge.java:729)
        at com.getcapacitor.BridgeActivity.onActivityResult(BridgeActivity.java:209)
        at android.app.Activity.dispatchActivityResult(Activity.java:7590)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4412)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4461)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6806)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
D/Capacitor: Sending plugin error: {"save":false,"callbackId":"39112375","pluginId":"GoogleAuth","methodName":"signIn","success":false,"error":{"message":"Something went wrong"}}
D/Capacitor/Plugin/App: Firing change: true
V/Capacitor/Plugin/App: Notifying listeners for event appStateChange
D/Capacitor/Plugin/App: No listeners found for event appStateChange
D/Capacitor: App resumed
V/Capacitor/Plugin/Network: Notifying listeners for event networkStatusChange
D/Capacitor/Plugin/Network: No listeners found for event networkStatusChange
V/Capacitor: callback: -1, pluginId: Console, methodName: log, methodData: {"level":"error","message":"LogError) An error has occurred: Something went wrong\n"}
E/Capacitor/Plugin/Console: LogError) An error has occurred: Something went wrong

Am investigating more, and will update this issue if I find the solution.

v2.0.0 doesn't work with androix appcompat

The version of google auth dependency you are using is using support v4 fragment, and if I use it with Capacitor 2 and androidx, it crash.

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/app/FragmentActivity;
04-07 15:17:02.335  1690  1786 E AndroidRuntime:        at com.google.android.gms.auth.api.signin.internal.zzh.zzc(Unknown Source:1)
04-07 15:17:02.335  1690  1786 E AndroidRuntime:        at com.google.android.gms.auth.api.signin.GoogleSignInClient.getSignInIntent(Unknown Source:20)
04-07 15:17:02.335  1690  1786 E AndroidRuntime:        at com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.signIn(GoogleAuth.java:54)
04-07 15:17:02.335  1690  1786 E AndroidRuntime:        ... 7 more

I think you should use the latest version, it works fine on my project now :

implementation 'com.google.android.gms:play-services-auth:16.+'

replace with :
implementation 'com.google.android.gms:play-services-auth:18.+'

Source : https://developers.google.com/android/guides/setup

Unhandled Promise rejection on signIn

Hi there,

I'm trying to handle the case when the user interrupts the login process, cancels the login window or the authorization window, but it always throws an error.

I tried multiple ways to avoid this issue.

First i tried to put the await in a try-catch block.

try {
let googleUser = await Plugins.GoogleAuth.signIn();
} catch (error) {
console.log('User interrupted the login process', error);
}

But it didn't work, because it threw this error
ERROR Error: Uncaught (in promise): Object: {"error":"popup_closed_by_user"}
Then i tried to catch it like a promise error.

Plugins.GoogleAuth.signIn().then((googleUser)=>{
...
}).catch((error)=>{
console.log('User interrupted the login process', error);
})

This threw the same error as before.
EDIT:
This issue is present on WEB only, when i import the module, it gets imported on iOS too and all the methods get overridden.

Im guessing the signIn method misses an error catch here.

await gapi.auth2.getAuthInstance().signIn();

or here:

const offlineAccessResponse = await gapi.auth2.getAuthInstance().grantOfflineAccess();

Deprecated API Usage UIWebView APIs

Could you help please, after adding your package to application, Apple was start warning about deprecated api usage, UIWebView APIs. But in your package files I did not find any mention of this api. Are you using some old version of capasitor / cordova or is the problem different?

MainActivity add(GoogleAuth.class);

Simple question. I have added to the init method in MainActivity like the docs suggest. However, I'm not sure what the import for add(GoogleAuth.class); is? Please let me know what the import is? Thanks.

import <Something>
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{ add(GoogleAuth.class); }});

"error":"popup_closed_by_user"

In web i am facing "error":"popup_closed_by_user" this issue and in android app created in typescirpt angular ionic just opening mail id list but after clicking on it nothing is happening

Generating New Access Token After Being Expired

The authentication is working great for me in browser and on iOS, however after the access_token expires, I start getting invalid_token when making requests to Google's API. Is there a way to refresh the access_token?

Looking at the source, it appears only signIn() and signOut are implemented. However looks like you're calling await googleUser.reloadAuthResponse(); in signIn. Would exposing this as a method help generate a new access_token?

[Capacitor Plugin Error] - GoogleAuth - signIn - Unable to serialize plugin ...

Got Error, and no data retrieved:
[Capacitor Plugin Error] - GoogleAuth - signIn - Unable to serialize plugin response as JSON.Ensure that all data passed to success callback from module method is JSON serializable!

If i commented the code for imageUrl in Plugin.swift(line:88), the error vanished, and got the user data.
// "imageUrl": user.profile.imageURL(withDimension: 100),

How to use this with ionic?

import { Plugins } from '@capacitor/core';
Plugins.GoogleAuth.signIn();
not working in angular.
This plugin was a big waste of time.

what is the option argument that needs to be passed in GoogleAuth.signIn()?

google error
as u can see this is error iam facing right now ? what is the value argument option required by the method?
Ionic info below

Ionic:

   Ionic CLI                     : 5.2.7 (C:\Users\Adit\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 5.1.1
   @angular-devkit/build-angular : 0.901.6
   @angular-devkit/schematics    : 9.1.6
   @angular/cli                  : 9.1.6
   @ionic/angular-toolkit        : 2.2.0

Capacitor:

   Capacitor CLI   : 2.2.0
   @capacitor/core : 2.2.0

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v10.16.3 (C:\Program Files\nodejs\node.exe)
   npm    : 6.11.3
   OS     : Windows 10

Prevent error from being thrown if not using plugin for web

I'm currently implementing this plugin for iOS and Android only and noticed that if I don't include the client ID meta tag I get the following error in the browser:

zone.js:703 Unhandled Promise rejection: Cannot read property 'content' of undefined ; Zone: <root> ; Task: null ; Value: TypeError: Cannot read property 'content' of undefined
    at HTMLScriptElement.<anonymous> (web.js:33)
    at Generator.next (<anonymous>)
    at web.js:6
    at new ZoneAwarePromise (zone.js:931)
    at push../node_modules/@codetrix-studio/capacitor-google-auth/dist/esm/web.js.__awaiter (web.js:2)
    at web.js:31
    at platform.js:23
    at jb (platform.js:15)
    at ea (platform.js:23)
    at Array.Qb.F.<computed> (platform.js:23) TypeError: Cannot read property 'content' of undefined
    at HTMLScriptElement.<anonymous> (http://localhost:8100/vendor.js:94921:84)
    at Generator.next (<anonymous>)
    at http://localhost:8100/vendor.js:94894:71
    at new ZoneAwarePromise (http://localhost:8100/polyfills.js:3936:29)
    at push../node_modules/@codetrix-studio/capacitor-google-auth/dist/esm/web.js.__awaiter (http://localhost:8100/vendor.js:94890:12)
    at http://localhost:8100/vendor.js:94919:34
    at https://apis.google.com/js/platform.js:23:215
    at jb (https://apis.google.com/js/platform.js:15:467)
    at ea (https://apis.google.com/js/platform.js:23:198)
    at Array.Qb.F.<computed> (https://apis.google.com/js/platform.js:23:301)

I'm hoping there is an easy way to remove this error without adding the meta tag. Thanks!

Add custom scopes

Scopes can be added in the load() method by assigning to the scopes property of .sharedInstance()

For example

GIDSignIn.sharedInstance().scopes = ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"]

I'm not sure what the best way to load this data from a plist is, or if their's a better way to store it but it would be very useful addition, for my use case at least, to customize the scopes available.

Android Error on Google Sign In

here is the logcat said:

2020-05-16 22:42:54.137 1950-1950/com.lesjaw.astropasaraya E/Capacitor/Plugin: Something went wrong
    com.google.android.gms.common.api.ApiException: 10: 
        at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(com.google.android.gms:play-services-base@@17.1.0:4)
        at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(com.google.android.gms:play-services-auth@@18.0.0:9)
        at com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth.handleOnActivityResult(GoogleAuth.java:71)
        at com.getcapacitor.Bridge.onActivityResult(Bridge.java:765)
        at com.getcapacitor.BridgeActivity.onActivityResult(BridgeActivity.java:211)
        at android.app.Activity.dispatchActivityResult(Activity.java:7454)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4353)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4402)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2020-05-16 22:42:54.138 1950-1950/com.lesjaw.astropasaraya D/Capacitor: Sending plugin error: {"save":false,"callbackId":"115071079","pluginId":"GoogleAuth","methodName":"signIn","success":false,"error":{"message":"Something went wrong"}}
2020-05-16 22:42:54.145 1950-1950/com.lesjaw.astropasaraya D/Capacitor/App: Firing change: true
2020-05-16 22:42:54.146 1950-1950/com.lesjaw.astropasaraya D/Capacitor/App: No listeners found for event appStateChange
2020-05-16 22:42:54.166 1950-1950/com.lesjaw.astropasaraya D/Capacitor: App resumed

Issue when try to register the plugin on Capacitor.

I have this error when trying to register the plugin, do you know what could be the issue?

Unhandled Promise rejection: Cannot read property 'GoogleAuth' of undefined ; Zone: <root> ; Task: null ; Value: TypeError: Cannot read property 'GoogleAuth' of undefined

Error when try to register the plugin

I have this error when try to register the plugin, do you know what could be the issue?

Unhandled Promise rejection: Cannot read property 'GoogleAuth' of undefined ; Zone: <root> ; Task: null ; Value: TypeError: Cannot read property 'GoogleAuth' of undefined

Something went wrong

I try use that plugin in Android but when I use the return is Something went wrong

Screen Shot 2020-04-09 at 1 36 06 PM

Errors when build on Xcode

Screen Shot 2020-04-23 at 3 20 55 pm

I'm getting attached screen shot errors when I try to build the project in Xcode.

any recommendation, how I can fix it ? Thanks

Using
"@codetrix-studio/capacitor-google-auth": "^2.1.0",

Update:
I have downgrade into version 2 and Xcode build successfully , Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.