mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-23 10:39:09 +00:00
hubspot oauth
This commit is contained in:
@@ -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