mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-15 10:59:08 +00:00
hubspot oauth
This commit is contained in:
Generated
+83
@@ -29,6 +29,7 @@
|
||||
"jwk-to-pem": "^2.0.5",
|
||||
"passport": "^0.6.0",
|
||||
"passport-hubspot": "^0.1.0",
|
||||
"passport-hubspot-oauth2": "^1.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.5",
|
||||
@@ -7236,6 +7237,47 @@
|
||||
"passport-oauth2": "^1.1.2"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-hubspot-oauth2": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/passport-hubspot-oauth2/-/passport-hubspot-oauth2-1.0.3.tgz",
|
||||
"integrity": "sha512-YQyZ9dMxyDJI4vHtq/FXKxEQx39EdODWkn7yp+y12FQBKUXEWN4p2XRO5znwTKyFc1ALwDgCGRxNnRpx7F7gZA==",
|
||||
"dependencies": {
|
||||
"passport-oauth": "~1.0.0",
|
||||
"pkginfo": "0.2.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.2"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-oauth": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-oauth/-/passport-oauth-1.0.0.tgz",
|
||||
"integrity": "sha512-4IZNVsZbN1dkBzmEbBqUxDG8oFOIK81jqdksE3HEb/vI3ib3FMjbiZZ6MTtooyYZzmKu0BfovjvT1pdGgIq+4Q==",
|
||||
"dependencies": {
|
||||
"passport-oauth1": "1.x.x",
|
||||
"passport-oauth2": "1.x.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-oauth1": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-oauth1/-/passport-oauth1-1.2.0.tgz",
|
||||
"integrity": "sha512-Sv2YWodC6jN12M/OXwmR4BIXeeIHjjbwYTQw4kS6tHK4zYzSEpxBgSJJnknBjICA5cj0ju3FSnG1XmHgIhYnLg==",
|
||||
"dependencies": {
|
||||
"oauth": "0.9.x",
|
||||
"passport-strategy": "1.x.x",
|
||||
"utils-merge": "1.x.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/jaredhanson"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-oauth2": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/passport-oauth2/-/passport-oauth2-1.6.1.tgz",
|
||||
@@ -7353,6 +7395,14 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/pkginfo": {
|
||||
"version": "0.2.3",
|
||||
"resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.2.3.tgz",
|
||||
"integrity": "sha512-7W7wTrE/NsY8xv/DTGjwNIyNah81EQH0MWcTzrHL6pOpMocOGZc0Mbdz9aXxSrp+U0mSmkU8jrNCDCfUs3sOBg==",
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pluralize": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz",
|
||||
@@ -14774,6 +14824,34 @@
|
||||
"passport-oauth2": "^1.1.2"
|
||||
}
|
||||
},
|
||||
"passport-hubspot-oauth2": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/passport-hubspot-oauth2/-/passport-hubspot-oauth2-1.0.3.tgz",
|
||||
"integrity": "sha512-YQyZ9dMxyDJI4vHtq/FXKxEQx39EdODWkn7yp+y12FQBKUXEWN4p2XRO5znwTKyFc1ALwDgCGRxNnRpx7F7gZA==",
|
||||
"requires": {
|
||||
"passport-oauth": "~1.0.0",
|
||||
"pkginfo": "0.2.x"
|
||||
}
|
||||
},
|
||||
"passport-oauth": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-oauth/-/passport-oauth-1.0.0.tgz",
|
||||
"integrity": "sha512-4IZNVsZbN1dkBzmEbBqUxDG8oFOIK81jqdksE3HEb/vI3ib3FMjbiZZ6MTtooyYZzmKu0BfovjvT1pdGgIq+4Q==",
|
||||
"requires": {
|
||||
"passport-oauth1": "1.x.x",
|
||||
"passport-oauth2": "1.x.x"
|
||||
}
|
||||
},
|
||||
"passport-oauth1": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-oauth1/-/passport-oauth1-1.2.0.tgz",
|
||||
"integrity": "sha512-Sv2YWodC6jN12M/OXwmR4BIXeeIHjjbwYTQw4kS6tHK4zYzSEpxBgSJJnknBjICA5cj0ju3FSnG1XmHgIhYnLg==",
|
||||
"requires": {
|
||||
"oauth": "0.9.x",
|
||||
"passport-strategy": "1.x.x",
|
||||
"utils-merge": "1.x.x"
|
||||
}
|
||||
},
|
||||
"passport-oauth2": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/passport-oauth2/-/passport-oauth2-1.6.1.tgz",
|
||||
@@ -14857,6 +14935,11 @@
|
||||
"find-up": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"pkginfo": {
|
||||
"version": "0.2.3",
|
||||
"resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.2.3.tgz",
|
||||
"integrity": "sha512-7W7wTrE/NsY8xv/DTGjwNIyNah81EQH0MWcTzrHL6pOpMocOGZc0Mbdz9aXxSrp+U0mSmkU8jrNCDCfUs3sOBg=="
|
||||
},
|
||||
"pluralize": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz",
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
"jwk-to-pem": "^2.0.5",
|
||||
"passport": "^0.6.0",
|
||||
"passport-hubspot": "^0.1.0",
|
||||
"passport-hubspot-oauth2": "^1.0.3",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.5",
|
||||
|
||||
+3
-1
@@ -31,7 +31,8 @@ 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/inputs/passport-strategies/hubspot';
|
||||
import { HubspotStrategy } from './modules/oauth/passport-strategies/hubspot';
|
||||
import { OauthController } from './modules/oauth/oauth.controller';
|
||||
|
||||
const authClient = new AuthClient();
|
||||
const inputClient = new InputsClientConfiguration();
|
||||
@@ -48,6 +49,7 @@ const transformationClient = new TransformationsClientConfiguration();
|
||||
AuthController,
|
||||
HealthController,
|
||||
CatalogController,
|
||||
OauthController,
|
||||
],
|
||||
providers: [
|
||||
InputsService,
|
||||
|
||||
@@ -6,8 +6,6 @@ import {
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Req,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { InputsService } from './inputs.service';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
@@ -23,7 +21,6 @@ import {
|
||||
TestConnectionReq,
|
||||
TestConnectionRes,
|
||||
} from './dtos/input.model';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
|
||||
@ApiTags('inputs')
|
||||
@Controller('inputs')
|
||||
@@ -128,14 +125,4 @@ export class InputsController {
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('hubspot'))
|
||||
@Get('oauth/hubspot')
|
||||
async oauthHubspot(@Req() req) {
|
||||
return true;
|
||||
}
|
||||
@Get('oauth/hubspot/callback')
|
||||
async oauthHubspotCallback(@Req() req) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { Strategy } from 'passport-hubspot';
|
||||
import { PassportStrategy } from '@nestjs/passport';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class HubspotStrategy extends PassportStrategy(Strategy) {
|
||||
constructor() {
|
||||
super({
|
||||
clientID: 'asd',
|
||||
clientSecret: '',
|
||||
callbackURL: 'http://localhost:4200/coletix/auth-callback',
|
||||
});
|
||||
}
|
||||
|
||||
async validate(accessToken: string, refreshToken: string) {
|
||||
return { accessToken, refreshToken };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Controller, Get, Req, UseGuards } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
|
||||
@ApiTags('oauth')
|
||||
@Controller('oauth')
|
||||
export class OauthController {
|
||||
@UseGuards(AuthGuard('hubspot'))
|
||||
@Get('hubspot')
|
||||
async oauthHubspot(@Req() req) {
|
||||
console.log(req);
|
||||
return true;
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard('hubspot'))
|
||||
@Get('hubspot/callback')
|
||||
async oauthHubspotCallback() {
|
||||
console.log('hubspot/callback');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Strategy } from 'passport-hubspot-oauth2';
|
||||
import { PassportStrategy } from '@nestjs/passport';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class HubspotStrategy extends PassportStrategy(Strategy) {
|
||||
constructor() {
|
||||
super(
|
||||
{
|
||||
clientID: 'c51bc9c9-e81c-4263-887e-7cc68ab8e185',
|
||||
clientSecret: '99a8bb9d-b622-4ea7-a46c-77b74f98ce80',
|
||||
callbackURL: 'http://localhost:3333/oauth/hubspot/callback',
|
||||
redirectUri: 'http://localhost:3333/oauth/hubspot/callback',
|
||||
scope:
|
||||
'automation business-intelligence oauth forms integration-sync sales-email-read crm.lists.read crm.objects.contacts.read crm.schemas.contacts.read crm.objects.companies.read crm.objects.deals.read crm.schemas.companies.read crm.schemas.deals.read crm.objects.owners.read crm.objects.quotes.read crm.schemas.quotes.read crm.objects.line_items.read crm.schemas.line_items.read',
|
||||
passReqToCallback: true,
|
||||
},
|
||||
(accessToken, refreshToken, tokenInfo, profile, done) => {
|
||||
return done(null, profile, { accessToken, refreshToken, tokenInfo });
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
authenticate(req, options) {
|
||||
options.state = 'customer_id';
|
||||
super.authenticate(req, options);
|
||||
}
|
||||
}
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user