我想根据谷歌的访问令牌为我的路由控制器使用保护,但我不知道如何实现这一点。
我从我的 google oauth 中检索了这个
{
"message": "User information from google",
"user": {
"email": "test@gmail.com",
"firstName": "John",
"lastName": "Kennedy",
"picture":
"https://lh3.googleusercontent.com/a-/mypicture",
"accessToken": "myaccesstoken"
}
}
现在我不知道如何将此访问令牌用于我的其他路由,例如在控制器中:
@UseGuards() // I don't know what to put here
@Get('/get_customer/:id')
async findCustomerById(@Param() params): Promise<Customer> {
try {
return await this.stripeService.findCustomerById(params.id);
} catch (e) {
throw new Error(e.message);
}
}