mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-07 04:39:07 +00:00
FIX: google strategy different callbacks for google
This commit is contained in:
@@ -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
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user