codetrixstudio / capacitorgoogleauth Goto Github PK
View Code? Open in Web Editor NEWCapacitor plugin for Google Auth. Lightweight & no dependencies.
License: MIT License
Capacitor plugin for Google Auth. Lightweight & no dependencies.
License: MIT License
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
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?
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"
}
}
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
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.
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.
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);
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!
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.
I follow the steps:
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|'
That is the locations for GoogleService-Info.plist
and Info.plist
My GoogleService-Info.plist
have the CLIENT_ID
and REVERSED_CLIENT_ID
My Info.plist
have the `REVERSED_CLIENT_ID as an url scheme:
My capacitor.config.json
:
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)
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.
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 :-)
https://github.com/ionic-team/capacitor/releases/tag/2.0.0-beta.0
Plugin does'n work with beta version.
I fixed it by change in android/src/main/res/layout/bridge_layout_main.xml
android.support.design.widget.CoordinatorLayout
to androidx.coordinatorlayout.widget.CoordinatorLayout
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)
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?
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!
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
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"
]
},
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"}}
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
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'
Plugin.swift:21:9: Value of type 'GIDSignIn' has no member 'uiDelegate'; did you mean 'delegate'?
Plugin.swift:39:21: Value of type 'GIDSignIn' has no member 'hasAuthInKeychain'
Plugin.swift:40:22: Value of type 'GIDSignIn' has no member 'signInSilently'
Plugin.swift:73:53: Extra argument 'sourceApplication' in call
Condition:
Pop up selection for google account appeared.
Returning from pop up selection, error.
Device:
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"}
Try with ionic, build for native ios.
Successfully sign-in, the return value didn't contain any user information.
Anyhow to retrieve it?
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
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.
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.
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 :
CapacitorGoogleAuth/android/build.gradle
Line 46 in d6e73f9
replace with :
implementation 'com.google.android.gms:play-services-auth:18.+'
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.
CapacitorGoogleAuth/src/web.ts
Line 50 in 24a6e1a
or here:
CapacitorGoogleAuth/src/web.ts
Line 47 in 24a6e1a
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?
Kindly let me know about these 2 variables as I am not able to find them.
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); }});
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
Currently there is no way to retrieve the authenticated user on app/script startup. This is sort of related to #26. Could a method be added to retrieve the user? Something similar to this method: https://developers.google.com/identity/sign-in/web/reference#googleauthcurrentuserget
I could submit a PR for web/android but I do not have access to an iOS setup to implement it.
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
?
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),
import { Plugins } from '@capacitor/core';
Plugins.GoogleAuth.signIn();
not working in angular.
This plugin was a big waste of time.
If this doesn't exist then I suppose this is a feature request. I would love to see the ability to add a parameter allowing users to always select a Google account to login with instead of automatically logging them in with the one they authenticated with. Similar to how it's handled for the web: https://stackoverflow.com/a/43727675/9281001
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
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!
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.
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
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
After I choose a Google account and then continue, the popup closed itself and then get the error "popup_closed_by_user".
I am using version 1.1.2
don't know what to do. documentation dont say. what do?
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.