twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
GNU Affero General Public License v3.0
15.59k stars 1.65k forks source link

Ask google for a new validation with a new scope for the aliases #6092

Closed bosiraphael closed 3 weeks ago

bosiraphael commented 1 month ago

We need to have access to all the email adresses of an account to correctly link the messages. We need to add a new scope https://www.googleapis.com/auth/profile.emails.read.

greptile-apps[bot] commented 1 month ago

To add the new scope https://www.googleapis.com/auth/profile.emails.read for accessing all email addresses of an account, update the following files:

  1. google-gmail.auth.strategy.ts:

    super({
     clientID: environmentService.getGoogleClientID(),
     clientSecret: environmentService.getGoogleClientSecret(),
     callbackURL: environmentService.getGoogleCallbackURL(),
     scope: [
       'https://www.googleapis.com/auth/gmail.readonly',
       'https://www.googleapis.com/auth/profile.emails.read', // Add this line
     ],
     passReqToCallback: true,
    });
  2. google.auth.strategy.ts:

    super({
     clientID: environmentService.getGoogleClientID(),
     clientSecret: environmentService.getGoogleClientSecret(),
     callbackURL: environmentService.getGoogleCallbackURL(),
     scope: [
       'https://www.googleapis.com/auth/userinfo.profile',
       'https://www.googleapis.com/auth/userinfo.email',
       'https://www.googleapis.com/auth/profile.emails.read', // Add this line
     ],
     passReqToCallback: true,
    });
  3. google-apis.auth.strategy.ts:

    super({
     clientID: environmentService.getGoogleClientID(),
     clientSecret: environmentService.getGoogleClientSecret(),
     callbackURL: environmentService.getGoogleCallbackURL(),
     scope: [
       'https://www.googleapis.com/auth/drive',
       'https://www.googleapis.com/auth/profile.emails.read', // Add this line
     ],
     passReqToCallback: true,
    });

References

/packages/twenty-server/src/core/auth/strategies/google-gmail.auth.strategy.ts /packages/twenty-server/src/core/auth/strategies/google.auth.strategy.ts /packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis.auth.strategy.ts

#### About Greptile This response provides a starting point for your research, not a precise solution. Help us improve! Please leave a ๐Ÿ‘ if this is helpful and ๐Ÿ‘Ž if it is irrelevant. [Ask Greptile](https://app.greptile.com/chat/github/twentyhq/twenty/main) ยท [Edit Issue Bot Settings](https://app.greptile.com/apps/github)