mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-19 11:19:08 +00:00
google oauth working
This commit is contained in:
Generated
+34
@@ -32,6 +32,7 @@
|
||||
"passport-facebook": "^3.0.0",
|
||||
"passport-google-oauth20": "^2.0.0",
|
||||
"passport-hubspot-oauth2": "^1.0.3",
|
||||
"passport-mailchimp": "^1.1.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.5",
|
||||
@@ -8231,6 +8232,23 @@
|
||||
"node": ">= 6.2"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-mailchimp": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-mailchimp/-/passport-mailchimp-1.1.0.tgz",
|
||||
"integrity": "sha512-drCP+TMv1hcFCZ8Nbjx2gzq4ovYyvGZzH8I9RiaVD5ArvaWL3BAf6KJsNMxoPPwZAZi5SX5NqbG46I+5cUzweg==",
|
||||
"dependencies": {
|
||||
"passport-oauth2": "^1.3.0",
|
||||
"pkginfo": "^0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-mailchimp/node_modules/pkginfo": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz",
|
||||
"integrity": "sha512-8xCNE/aT/EXKenuMDZ+xTVwkT8gsoHN2z/Q29l80u0ppGEXVvsKRzNMbtKhg8LS8k1tJLAHHylf6p4VFmP6XUQ==",
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-oauth": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-oauth/-/passport-oauth-1.0.0.tgz",
|
||||
@@ -16648,6 +16666,22 @@
|
||||
"pkginfo": "0.2.x"
|
||||
}
|
||||
},
|
||||
"passport-mailchimp": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-mailchimp/-/passport-mailchimp-1.1.0.tgz",
|
||||
"integrity": "sha512-drCP+TMv1hcFCZ8Nbjx2gzq4ovYyvGZzH8I9RiaVD5ArvaWL3BAf6KJsNMxoPPwZAZi5SX5NqbG46I+5cUzweg==",
|
||||
"requires": {
|
||||
"passport-oauth2": "^1.3.0",
|
||||
"pkginfo": "^0.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"pkginfo": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz",
|
||||
"integrity": "sha512-8xCNE/aT/EXKenuMDZ+xTVwkT8gsoHN2z/Q29l80u0ppGEXVvsKRzNMbtKhg8LS8k1tJLAHHylf6p4VFmP6XUQ=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"passport-oauth": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-oauth/-/passport-oauth-1.0.0.tgz",
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
"passport-facebook": "^3.0.0",
|
||||
"passport-google-oauth20": "^2.0.0",
|
||||
"passport-hubspot-oauth2": "^1.0.3",
|
||||
"passport-mailchimp": "^1.1.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.5",
|
||||
|
||||
+6
-1
@@ -31,9 +31,11 @@ import { InputsClientConfiguration } from './clients/inputs/client.config';
|
||||
import { PipelinesClientConfiguration } from './clients/pipelines/client.config';
|
||||
import { CatalogController } from './modules/catalog/catalog.controller';
|
||||
import { CatalogService } from './modules/catalog/catalog.service';
|
||||
import { HubspotStrategy } from './modules/oauth/passport-strategies/hubspot';
|
||||
import { OauthController } from './modules/oauth/oauth.controller';
|
||||
import { getOauthSecrets } from './utils/OauthSecrets';
|
||||
import { HubspotStrategy } from './modules/oauth/passport-strategies/hubspot-strategy';
|
||||
import { GoogleStrategy } from './modules/oauth/passport-strategies/google-strategy';
|
||||
import { FacebookStrategy } from './modules/oauth/passport-strategies/facebook-strategy';
|
||||
|
||||
const authClient = new AuthClient();
|
||||
const inputClient = new InputsClientConfiguration();
|
||||
@@ -66,7 +68,10 @@ const transformationClient = new TransformationsClientConfiguration();
|
||||
PipelinesClientService,
|
||||
AuthClientService,
|
||||
CatalogService,
|
||||
//OAUTH Passport Strategies
|
||||
HubspotStrategy,
|
||||
GoogleStrategy,
|
||||
FacebookStrategy,
|
||||
],
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
|
||||
@@ -78,7 +78,7 @@ export class OauthController {
|
||||
if (!authInfo) throw new BadRequestException('Oauth tokens not found');
|
||||
|
||||
const { accessToken: access_token, refreshToken: refresh_token } = authInfo;
|
||||
const { customer_id } = request.query;
|
||||
const { state: customer_id } = request.query;
|
||||
|
||||
const response = await this.inputService.create({
|
||||
info: { customer_id, customer: 'customer', user_id: 'empty' },
|
||||
|
||||
@@ -1,39 +1,47 @@
|
||||
import {
|
||||
Profile,
|
||||
Strategy,
|
||||
StrategyOptionsWithRequest,
|
||||
VerifyCallback,
|
||||
} from 'passport-google-oauth20';
|
||||
import { Profile, Strategy, StrategyOptions } from 'passport-google-oauth20';
|
||||
import { PassportStrategy } from '@nestjs/passport';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Inject, Injectable, Req } from '@nestjs/common';
|
||||
import { OauthSecrets } from 'src/utils/OauthSecrets';
|
||||
|
||||
@Injectable()
|
||||
export class GoogleStrategy extends PassportStrategy(Strategy) {
|
||||
export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
|
||||
constructor(
|
||||
@Inject('OAUTH_SECRETS')
|
||||
private readonly oauthSecrets: OauthSecrets,
|
||||
) {
|
||||
const options: StrategyOptionsWithRequest = {
|
||||
const options: StrategyOptions = {
|
||||
clientID: oauthSecrets.google.client_id,
|
||||
clientSecret: oauthSecrets.google.client_secret,
|
||||
scope: 'drive.metadata.readonly spreadsheets.readonly',
|
||||
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,
|
||||
passReqToCallback: true,
|
||||
};
|
||||
const verify = (
|
||||
accessToken: string,
|
||||
refreshToken: string,
|
||||
profile: Profile,
|
||||
done: VerifyCallback,
|
||||
) => done(null, profile, { accessToken, refreshToken });
|
||||
done,
|
||||
) => {
|
||||
console.log('verify');
|
||||
return done(null, profile, { accessToken, refreshToken });
|
||||
};
|
||||
|
||||
super(options, verify);
|
||||
}
|
||||
|
||||
authenticate(req, options) {
|
||||
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