Cap-go / capacitor-social-login

One plugin to make login with Google,Apple,Facebook and so on, simple and fast to implement
https://capgo.app
MIT License
20 stars 5 forks source link

Google login web not returning any data. #46

Open Saqib92 opened 6 days ago

Saqib92 commented 6 days ago

Google Login not working in browser. it open google login window and after authorizing it closes but data is not returning.

MalikHamza007 commented 5 days ago

Google Login not working in browser. it open google login window and after authorizing it closes but data is not returning.

Same issue with me :(

WcaleNieWolny commented 5 days ago

There is an open PR addressing this issue: #37

Saqib92 commented 2 days ago

Not working on web. Throwing this error on web. Before that at least Google Auth window were opening.

Screenshot 2024-11-06 at 1 00 47 PM

WcaleNieWolny commented 2 days ago

This does not look like a problem with the plugin. The stacktrace does not mention CapacitorSociaLogin once

MalikHamza007 commented 2 days ago

Not working on web. Throwing this error on web. Before that at least Google Auth window were opening.

Screenshot 2024-11-06 at 1 00 47 PM

Hey @Saqib92 this is my mail @hamza.ahtsham1@gmail.com

can you send me the sample code

Saqib92 commented 2 days ago

Not working on web. Throwing this error on web. Before that at least Google Auth window were opening. Screenshot 2024-11-06 at 1 00 47 PM

Hey @Saqib92 this is my mail @hamza.ahtsham1@gmail.com

can you send me the sample code

what issue are you facing. your image is broken.

Saqib92 commented 2 days ago

This does not look like a problem with the plugin. The stacktrace does not mention CapacitorSociaLogin once

my implementation:

async googleLogin() {
    let options: InitializeOptions = {};
    if (Capacitor.getPlatform() == 'ios') {
      options = {
        google: {
          iOSClientId: environment.google.iOSClientId, // the iOS client id
          iOSServerClientId: environment.google.iOSServerClientId // the iOS server client id (optional)
        },
      }
    } else {
      console.log('here')
      options = {
        google: {
          webClientId: environment.google.webClientId // the web client id for Android and Web
        }
      }
    }
    await SocialLogin.initialize(options);

    const res = await SocialLogin.login({
      provider: 'google',
      options: {
        scopes: ['email', 'profile'],
      },
    });
    console.log(res);
  }
luckashenri commented 1 day ago

Same here, no response after login at all. I'm trying google login

riderx commented 1 day ago

I'm looking with @Saqib92 to find a fix

Saqib92 commented 1 day ago

Demo Repo to reproduce issue: https://github.com/Saqib92/Saqib92-camera-preview-uploader-issue

WcaleNieWolny commented 1 day ago

@Saqib92 you want to remove scopes when calling login Right now, you are doing

    const res = await SocialLogin.login({
      provider: 'google',
      options: {
        scopes: ['email', 'profile'], // <--- this is bad
      },
    });

I did not implement scopes yet. It's something that could be implemented in the near future, but for the time being if you set scopes the code will reject your login

WcaleNieWolny commented 1 day ago

The correct way would be:

    const res = await SocialLogin.login({
      provider: 'google',
      options: {},
    });

This works better, but you get this error

image

Please make sure you don't have any redirect URLs added in the Google Console. This is clearly mentioned in the documentation image

Saqib92 commented 1 day ago

The correct way would be:

    const res = await SocialLogin.login({
      provider: 'google',
      options: {},
    });

This works better, but you get this error

image

Please make sure you don't have any redirect URLs added in the Google Console. This is clearly mentioned in the documentation image

Thank you, But i do require scopes as my app targets some sensitive scopes, like spreadsheet read and write permission via serverAuthCode and refresh token.

WcaleNieWolny commented 1 day ago

I could implement additional scopes, but first please make sure that your app works with the current version of the plugin.

Please let me know if removing scopes fixed your problem

Saqib92 commented 18 hours ago

I could implement additional scopes, but first please make sure that your app works with the current version of the plugin.

Please let me know if removing scopes fixed your problem

Yes, i can confirm it is working on Web WITHOUT scopes.

MalikHamza007 commented 3 hours ago

Hey @Saqib92 can i get your linkedin by any chance

cihakmar commented 3 hours ago

Hi,

I just build my app for production and tried google login on android device. After click on google login button the alert to select account is presented. After selecting account alert is closed but I have an error in sentry Google Sign-In failed: activity is cancelled by the user.. Could plese help?

EDIT: On debug version, it works like a charm.

Thanks

WcaleNieWolny commented 2 hours ago

What version are you on, and have you followed the setup guide?

cihakmar commented 2 hours ago

Sure, by the setup guide I have this function:

    let options: InitializeOptions = {};
    if (Capacitor.getPlatform() === 'ios') {
      options = {
        google: {
          iOSClientId: environment.googleIosClientId
        },
      }
    } else {
      options = {
        google: {
          webClientId: environment.googleWebClientId 
        }
      }
    }
    await SocialLogin.initialize(options);
    await this.loadingHelper.presentLoader(null, null, 'googleLoginApi()');

    try {
      const googleInit = await SocialLogin.initialize(options);
      Sentry.captureMessage('GOOGLE init resp: ' + JSON.stringify(googleInit));
      await this.loadingHelper.presentLoader(null, null, 'googleLoginApi()');
      const res = await SocialLogin.login({
        provider: 'google',
        options: {
          scopes: ['email', 'profile'],
        },
      });
      Sentry.captureMessage('GOOGLE login resp: ' + JSON.stringify(res));

      if (res && res.result.accessToken.token) {
        const profile = {
          token: res.result.accessToken.token,
          email: res.result.profile.email,
          // @ts-ignore
          fullName: res.result.profile.name
        };
        return profile;
      }
    } catch (e) {
      console.warn("GOOGLE LOGIN ERROR", e)
      Sentry.captureException('Error logging into GOOGLE: ' + JSON.stringify(e));
    }
  }

Version of @capgo/capacitor-social-login is 0.0.67. Other versions:

Ionic:

   Ionic CLI                     : 6.20.9 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : not installed
   @angular-devkit/build-angular : 18.2.11
   @angular-devkit/schematics    : 18.2.11
   @angular/cli                  : 18.2.11
   @ionic/angular-toolkit        : 11.0.1

Capacitor:

   Capacitor CLI      : 6.1.2
   @capacitor/android : 6.1.2
   @capacitor/core    : 6.1.2
   @capacitor/ios     : 6.1.2

Utility:

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

System:

   NodeJS : v20.14.0 (/Users/mc/.nvm/versions/node/v20.14.0/bin/node)
   npm    : 10.7.0
   OS     : macOS Unknown
Saqib92 commented 1 hour ago

Hey @Saqib92 can i get your linkedin by any chance

Please Email me at: najamsaqib0880@gmail.com

WcaleNieWolny commented 47 minutes ago

Can you try the "0.0.68-alpha.2" and follow the guide?