0

Referring to the following link https://cloud.google.com/sql/docs/mysql/admin-api/how-tos/authorizing . I've tried on the apikey but no success. The response from the API as follows;

//https://www.googleapis.com/sql/v1beta4/projects/<projectid>/instances/<instanceid>/databases?key=<API_KEY>

{
    "error": {
        "code": 401,
        "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
        "errors": [
            {
                "message": "Login Required.",
                "domain": "global",
                "reason": "required",
                "location": "Authorization",
                "locationType": "header"
            }
        ],
        "status": "UNAUTHENTICATED"
    }
}

I've no issue with oAUth 2.0, hence would like to confirm if authorization through api key is no more supported?

FRizal
  • 448
  • 7
  • 15

1 Answers1

0

I tested get information from the endpoint using only the API key and is not possible to retrieve information, since is necessary to use an authentication bearer.

I used these commands to get the databases information

export TOKEN=`gcloud auth application-default print-access-token`

curl -X GET \
  https://sqladmin.googleapis.com/sql/v1beta4/projects/[MY PROJECT ID]/instances/[MY INSTANCE NAME]/databases \
  -H 'authorization: Bearer '"$TOKEN"''

Since this request has sensitive data (non public) is necessary the OAuth token and the api key is not mandatory, as is stated on this document.

Looks like key parameter is not anymore necessary.

Jan Hernandez
  • 4,414
  • 2
  • 12
  • 18