abacritt / angularx-social-login

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

Possible to add scopes to the Google login button itself? #609

Closed mcantrell closed 1 year ago

mcantrell commented 1 year ago

We require the users to login to get basic profile info. There are some optional features that we provide which need new scopes but we don't want to prompt for these scopes unless they're needed.

Prior to the Google Identity Services refactor, we could simply call the authService.signIn method again with the newly requested scopes:

  login(fullScopes?: boolean) {
    this.loginScopes = fullScopes ? GOOGLE_FULL_SCOPES : GOOGLE_DEFAULT_SCOPES;
    console.log("Starting login", this.loginHint, this.loginScopes);
    this.loading = true;
    this.authService.signIn(GoogleLoginProvider.PROVIDER_ID, {
      login_hint: this.loginHint,
      scope: this.loginScopes
    });
  }

Now that authService.signIn has been removed from the Google provider, I'm not sure how we can implement similar functionality. Would it be possible to pass the scopes as an attribute to the sign in button?

mcantrell commented 1 year ago

After digging through the Google docs, it appears that the proper place to do incremental authorization is in the token client:

https://developers.google.com/identity/oauth2/web/guides/use-token-model#incremental_authorization

Maybe this option could be exposed via parameter in authService.getAccessToken?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.