Tuesday, January 19, 2016

Re: [google-cloud-sql-discuss] Testing Cloud SQL Failover

I still suggest trying gcloud auth print-access-token.

You might also want to try putting the access token into https://apis-explorer.appspot.com/apis-explorer/#search/oauth2/oauth2/v2/oauth2.tokeninfo and clicking execute. You should make sure that the scope includes those required by the API.  You should also check that the email returned has owner or editor permission on the project your instance is in.

On Tue, Jan 19, 2016 at 2:20 PM, Peter Cheesewright <peter@microcosm.co.uk> wrote:
The token I'm using does start "ya29."
It's the token obtained from the output of
gcloud auth login
after completing the web flow.

Any other thoughts?


On Tuesday, January 19, 2016 at 5:36:48 PM UTC, David Newgas wrote:
I suspect you might be using a "authorization code" rather than an "access token". The authorization code exchanged as part of the "gcloud auth login" flow is just part of the  login process. Try using "gcloud auth print-access-token" to actually get an access token you can use. Google's access tokens (currently) start with "ya29." which should help you identify it.

David

On Tue, Jan 19, 2016 at 9:16 AM, Peter Cheesewright <pe...@microcosm.co.uk> wrote:
I've been trying to test SQL failover using the following command:

curl --header 'Content-Type: application/json' --header 'Authorization: Bearer OATH_ACCESS_TOKEN_HERE' -X POST "https://www.googleapis.com/sql/v1beta4/projects/numeric-datum-118114/instances/asia-east1:db-master/failover" --data "{}"

I started with the command here:
but it seems to be a bit off the mark. Eventually I ended up with the curl command above but I keep getting the following response:

{
 
"error": {
 
"errors": [
   
{
   
"domain": "global",
   
"reason": "authError",
   
"message": "Invalid Credentials",
   
"locationType": "header",
   
"location": "Authorization"
   
}
 
],
 
"code": 401,
 
"message": "Invalid Credentials"
 
}
}

The actual access token I'm using in the curl command is the one returned by:
gcloud auth login

I'm assuming this is the wrong thing to do? 
How do I acquire an access token that allows me to make this call?

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/5ed3f23d-b82a-481f-8885-7b986bce0966%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/c2543eec-71ed-426f-a06f-6672c4a0012e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/CAJZK_baXxbZRhD0Ls2ntR4FVcNoD-EP1x-dOtwx%2B5597-w23GA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment