1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| import { Injectable } from '@nestjs/common'; import { JwtService } from '@nestjs/jwt'; import { v4 as uuid } from 'uuid'; import * as config from 'config';
const tableauConfig = config.get('tableau');
@Injectable() export class TableauService { constructor(private jwtService: JwtService) {}
async getTableauToken(username: string){ const token = await this.jwtService.sign( { iss: tableauConfig.connectedAppClientId, aud: 'tableau', jti: uuid(), sub: username, scp: [ 'tableau:view:embed', 'tableau:views:embed_authoring', ], }, { header: { alg: 'HS256', kid: tableauConfig.connectedAppSecretId, iss: tableauConfig.connectedAppClientId, }, secret: tableauConfig.secretvalue, expiresIn: '5m', }, ); return token; } }
|