I have been successfully running my Angular 5 app with Google authentication for some time, but out of nowhere I encountered this error (on both production and development). The sign-in process works fine and I am able to retrieve user details from the GoogleAuth object. However, I keep getting the following error:
Uncaught TypeError: googleAuth.then is not a function
Below is the code snippet. _googleAuth is a service that initiates the process.
this._googleAuth.getAuth()
.subscribe(googleAuth => {
// TODO
console.log('user signedIn: ', googleAuth.isSignedIn.get()); // this returns true
const self = this;
googleAuth.then(function() { // error occurs here
if (googleAuth.isSignedIn.get()) {
...
}
...
I have updated the typings to:
"@types/gapi": "0.0.35", "@types/gapi.auth2": "0.0.47",
Here is the getAuth function (which still seems to be working):
public getAuth(): Observable<GoogleAuth> {
if (!this.GoogleAuth) {
return this.googleApi.onLoad().mergeMap(() => this.loadGapiAuth());
}
return Observable.of(this.GoogleAuth);
}
I have verified that the typings do include GoogleAuth.then. Can anyone explain why I can obtain a GoogleAuth object but cannot invoke .then?
The official Google documentation for GoogleAuth.then can be found here: https://developers.google.com/identity/sign-in/web/reference#googleauththenoninit-onerror