Couldn't connect to database using Cloud SQL proxy

2/24/2018

When using the GCloud CLI to create the service accounts and keys I get the following error

2018/02/24 22:32:35 New connection for "moodle-proj-10:europe-west2:mysqlinst10"
2018/02/24 22:32:35 couldn't connect to "moodle-proj-10:europe-west2:mysqlinst10": ensure that the account has access to "moodle-proj-10:europe-west2:mysqlinst10" (and make sure there's no typo in that name). Error during createEphemeral for moodle-proj-10:europe-west2:mysqlinst10: googleapi: Error 403: The client is not authorized to make this request., notAuthorized

When I delete the service accounts and corresponding keys are re-create it using the console, the error changes to the error below

2018/02/24 23:21:25 couldn't connect to "moodle-proj-10:europe-west2:mysqlinst10": Post https://www.googleapis.com/sql/v1beta4/projects/moodle-proj-10/instances/mysqlinst10/createEphemeral?alt=json: oauth2: cannot fetch token: 400 Bad Request
Response: {
  "error" : "invalid_grant",
  "error_description" : "Invalid JWT Signature."
}

Has anyone experienced this?

-- Shiyghan Navti
google-cloud-platform
google-cloud-sql
kubernetes

1 Answer

12/1/2019

I had this problem when I followed the command line instructions in this help article

Solution is to delete the original service account and create a new one in the console using this help article.

-- Cameron Rout
Source: StackOverflow