FIX: google strategy different callbacks for google

This commit is contained in:
Gabriel Rosa
2022-06-27 14:13:18 -03:00
parent 2f5d940b46
commit 7012a6e2ac
3 changed files with 7 additions and 15 deletions
-12
View File
@@ -37,18 +37,6 @@ export class OauthController {
return await this.callback(req, 'hubspot');
}
@Get('google')
@UseGuards(AuthGuard('google'))
async oauthGoogle() {
return true;
}
@Get('google/callback')
@UseGuards(AuthGuard('google'))
@Redirect()
async oauthGoogleCallback(@Req() req) {
return await this.callback(req, 'googleads');
}
@Get('googleads')
@UseGuards(AuthGuard('google'))
async oauthGoogleAds() {
@@ -31,13 +31,17 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
const path: string = req.route.path;
const { customer_id } = req.query;
const scope: string[] = ['https://www.googleapis.com/auth/userinfo.email'];
if (path.includes('googleads'))
if (path.includes('googleads')) {
scope.push('https://www.googleapis.com/auth/adwords');
if (path.includes('google-sheets'))
options.callbackURL = '/oauth/googleads/callback';
}
if (path.includes('google-sheets')) {
scope.push(
'https://www.googleapis.com/auth/drive.metadata.readonly',
'https://www.googleapis.com/auth/spreadsheets.readonly',
);
options.callbackURL = '/oauth/google-sheets/callback';
}
options.scope = scope;
options.state = customer_id;
options.accessType = 'offline';
+1 -1
View File
File diff suppressed because one or more lines are too long