【发布时间】:2022-12-22 02:46:26
【问题描述】:
**This is my code when I'm creating the class and the method:**
@Injectable()
export class MicrosoftGraph {
constructor(private httpService: HttpService) {}
getMicrosoftGraphToken() {
const data = {
client_id: 'myclientid',
scope: 'https://graph.microsoft.com/.default',
client_secret: 'myclientsecret',
grant_type: 'client_credentials'
}
const url =
'https://login.microsoftonline.com/mytenantid/oauth2/v2.0/token';
const response = this.httpService.post(url, data).pipe(
tap((resp) => console.log(resp)),
map((resp) => resp.data),
tap((data) => console.log(data)),
);
console.log(response);
return response;
}
}
这是控制器的一部分:
@Controller('user')
export class UsersController {
constructor(private readonly microsoftGraph: MicrosoftGraph) {}
@Get('hola')
intento(@Res() res: Response, @Req() req: Request){
return this.microsoftGraph.getMicrosoftGraphToken();
}
}
这是我得到的错误:
Observable {
source: Observable {
source: Observable {
source: [Observable],
operator: [Function (anonymous)]
},
operator: [Function (anonymous)]
},
operator: [Function (anonymous)]
}
[Nest] 19464 - 08/30/2022, 8:05:31 AM ERROR [ExceptionsHandler] Request failed with status code 400
[Nest] 19464 - 08/30/2022, 8:05:31 AM ERROR [ExceptionsHandler] undefined
我正在尝试让这个令牌能够实现一个功能,我可以在其中拉出我公司的用户列表,请帮助并感谢
【问题讨论】:
标签: javascript node.js typescript microsoft-graph-api nestjs