mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-28 10:49:07 +00:00
FEAT: Mailchimp strategy
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { Profile, Strategy, StrategyOptions } from 'passport-google-oauth20';
|
||||
import { PassportStrategy } from '@nestjs/passport';
|
||||
import { Inject, Injectable, Req } from '@nestjs/common';
|
||||
import { OauthSecrets } from 'src/utils/OauthSecrets';
|
||||
|
||||
@Injectable()
|
||||
export class MailChimpStrategy extends PassportStrategy(Strategy, 'google') {
|
||||
constructor(
|
||||
@Inject('OAUTH_SECRETS')
|
||||
private readonly oauthSecrets: OauthSecrets,
|
||||
) {
|
||||
const options: StrategyOptions = {
|
||||
clientID: oauthSecrets.google.client_id,
|
||||
clientSecret: oauthSecrets.google.client_secret,
|
||||
scope: [
|
||||
'https://www.googleapis.com/auth/drive.metadata.readonly',
|
||||
'https://www.googleapis.com/auth/spreadsheets.readonly',
|
||||
'https://www.googleapis.com/auth/userinfo.email',
|
||||
],
|
||||
callbackURL: oauthSecrets.google.redirect_uri,
|
||||
};
|
||||
const verify = (
|
||||
accessToken: string,
|
||||
refreshToken: string,
|
||||
profile: Profile,
|
||||
done,
|
||||
) => {
|
||||
console.log('verify');
|
||||
return done(null, profile, { accessToken, refreshToken });
|
||||
};
|
||||
|
||||
super(options, verify);
|
||||
}
|
||||
|
||||
authenticate(@Req() req, options) {
|
||||
const { customer_id } = req.query;
|
||||
options.state = customer_id;
|
||||
options.accessType = 'offline';
|
||||
options.prompt = 'consent';
|
||||
super.authenticate(req, options);
|
||||
}
|
||||
|
||||
async validate(...args) {
|
||||
console.log('validate');
|
||||
console.log(args);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user