0

I am new to GCP and deployed one of the sample spring boot app with mysql db connection. while calling a rest APIs getting below exception. What could be the reason for the same.

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}

Below endpoint works fine

@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);
    }

}

getting exception for below endpoints

@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);
    }
}
Mr bond
  • 133
  • 2
  • 13
  • It's probably because your instance doesn't have a service account with permission to view, edit or create Cloud SQL tables. – Yogesh Jun 26 '21 at 07:32
  • Have you included the path in bitnami-apps-prefix.conf, in case you have updated the httpd-app.conf for your custom application? – RTXGamer Jun 26 '21 at 07:57
  • Please provide more details about your use case and GCP services you're using. – Serhii Rohoza Jun 28 '21 at 13:08
  • This error indicates a permission issue. Documentation for granting MySQL database access to your service account: https://cloud.google.com/sql/docs/mysql/authentication#user_and_service_account_administration – Elena Felder Jul 26 '21 at 15:19

0 Answers0