调用 REST API 时 GCP 中的异常

问题描述

我是 GCP 的新手,并使用 MysqL db 连接部署了示例 Spring Boot 应用程序之一。在调用低于异常的其余 API 时。可能是什么原因造成的。

2021-06-26T05:56:35.029691281Zcom.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
Info
2021-06-26T05:56:35.029699031Z{
Info
2021-06-26T05:56:35.029705107Z "code" : 403,Info
2021-06-26T05:56:35.029711431Z "errors" : [ {
2021-06-26T05:56:35.029717697Z "domain" : "global",Info
2021-06-26T05:56:35.029723141Z "message" : "Insufficient Permission",Info
2021-06-26T05:56:35.029729203Z "reason" : "insufficientPermissions"
Info
2021-06-26T05:56:35.029735192Z } ],Info
2021-06-26T05:56:35.029741632Z "message" : "Request had insufficient authentication scopes.",Info
2021-06-26T05:56:35.029747360Z "status" : "PERMISSION_DENIED"
Info
2021-06-26T05:56:35.029753095Z}

低于端点工作正常

@SpringBootApplication
public class EmployeeJdbcApplication {

    @RequestMapping("/")
    String home() {
        return "This is sample jdbc MysqL connection app.....";
    }
    
    public static void main(String[] args) {
        SpringApplication.run(EmployeeJdbcApplication.class,args);
    }

}

获取以下端点的异常

@RestController
public class EmployeeController {

    @Autowired
    EmployeeService empService;

    @RequestMapping(value = "/employees",method = RequestMethod.GET)
    public List<Employee> getEmployees() {

        return empService.getAllEmployees();

    }
    
    @RequestMapping(value = "/insertemployee",method = RequestMethod.POST)
    public void insertEmployee(@RequestBody Employee employee) {
        empService.insertEmployee(employee);
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)