mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-16 16:19:09 +00:00
hubspot oauth
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user