Stack Overflow is the best place to ask questions for GCP.

The documentation does describe how to authenticate to this API. If I
recall correctly, API keys are not supported.


On Dec 21, 2017 2:46 AM, "Sathish VJ" <sathis...@gmail.com> wrote:


I'm trying to make an api call to google vision api using an api key from
golang.  But I'm getting a 400: bad request, invalid_grant error.
What is the right way to make this call?


import (
        // ...
"google.golang.org/api/option"
vision "cloud.google.com/go/vision/apiv1"
"golang.org/x/net/context"
)

func getImageLabels(filename string) []string {

ctx := context.Background()

apiKey := "..." // my api key has been generated in the console and should
be fine.
apiKeyOption := option.WithAPIKey(apiKey)

client, err := vision.NewImageAnnotatorClient(ctx, apiKeyOption)

        // ...
        labels, err := client.DetectLabels(ctx, image, nil, 10)

}

*Failed to detect labels: rpc error: code = Internal desc = transport:
oauth2: cannot fetch token: 400 Bad Request*
*Response: {*
*  "error" : "invalid_grant"*
*}*

p.s. is there a specific group for gcp+golang that I should preferably post
this to?

-- 
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to