abacritt / angularx-social-login

Social login and authentication module for Angular 17
636 stars 387 forks source link

Cannot read properties of undefined (reading 'signIn') #496

Closed theAndEx closed 2 years ago

theAndEx commented 2 years ago

Hello, I have this error:

abacritt-angularx-social-login.js:85 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'signIn') at abacritt-angularx-social-login.js:85:30 at new Promise (<anonymous>) at GoogleLoginProvider.signIn (abacritt-angularx-social-login.js:82:16) at abacritt-angularx-social-login.js:267:26

I do everything according to the instructions. As a result, I get here - this.auth2 = gapi.auth2.getAuthInstance(); and here: const promise = !offlineAccess ? this.auth2.signIn(signInOptions) : this.auth2.grantOfflineAccess(signInOptions); - undefined.

It's problem with Google. Facebook work good.

inthegarage commented 2 years ago

@AndyVolf Looks like the auth initialisation (deprecated problem also in this issue list) is causing the whole thing to bomb now. This happens on this library and the old one.

inthegarage commented 2 years ago

@AndyVolf I will provide an emergency PR to the owner, whether it's used remains to be seen.

inthegarage commented 2 years ago

@jaibatrik Can I be added as contributor, my PR is ready.

theAndEx commented 2 years ago

@inthegarage The most interesting thing is that I took the Client ID from the demo and everything works. Apparently, there is something with my Clint ID, but I can’t even understand what the problem is .. because I do everything according to the instructions from the Internet (I create an application and make an OAuth 2.0 Client ID for a web application)..

inthegarage commented 2 years ago

@inthegarage The most interesting thing is that I took the Client ID from the demo and everything works. Apparently, there is something with my Clint ID, but I can’t even understand what the problem is .. because I do everything according to the instructions from the Internet (I create an application and make an OAuth 2.0 Client ID for a web application)..

I have the same problem, I didn't try the demo, but the Google API now throws an error instead of what I can only assume was just a warning message in the payload. I'm not 100% convinced about my PR, but it would hopefully get people running whilst things are recoded. In the meantime I followed this migration guide instead and that worked fully for me: https://developers.google.com/identity/oauth2/web/guides/migration-to-gis

It can easily be placed into an Angular app, and is a lot less code than the previous solution. My advice would be to follow the migration guide and just do the auth yourself.

jaibatrik commented 2 years ago

Hey I'll review this over the weekend. Thanks for sending the PR.

jaibatrik commented 2 years ago

Oh, and I don't see any PR in the repo though.

Heatmanofurioso commented 2 years ago

@inthegarage You can add one from a fork

inthegarage commented 2 years ago

@jaibatrik @Heatmanofurioso that is now complete. Please review and merge when you have time. Testing an linting all pasted and I'm now able to log in again.

Heatmanofurioso commented 2 years ago

@inthegarage @AndyVolf The PR's been merged, and is going to be deployed now. Can we close this specific issue?

inthegarage commented 2 years ago

@Heatmanofurioso Fine by me.