Permission denied error creating a product set in google cloud vision product search

1,139 views
Skip to first unread message

Eric Flores Godinez

unread,
Feb 19, 2020, 6:22:37 PM2/19/20
to cloud-vision-discuss
Hi

I am trying to create a product set on Google Cloud Vision Product Search, but I am getting a Permission denied error.


The Cloud Vision API is enabled in my project and the the service account key has Owner role. So, I do not know what is going on here.


Request:

curl -X POST -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" -H "Content-Type: application/json; charset=utf-8" --data @./request.json "https://vision.googleapis.com/v1/projects/$PROJECT/locations/$LOCATION/productSets"

Error:


{ "error": { "code": 403, "message": "Permission denied.", "status": "PERMISSION_DENIED"


Would you mind helping me on this please?


Thanks Eric

Jinjun (Cloud Platform Support)

unread,
Feb 20, 2020, 4:10:38 PM2/20/20
to cloud-vision-discuss
Hi Eric,

Among all the steps in our quickstart sample [1], you may have missed Step 5. Once you have the service account key, you need to set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the key file. Please check the sample in the documentation on how to do this in Linux, macOS or Windows.


Ashish Jaipur

unread,
Mar 23, 2021, 4:41:35 AM3/23/21
to cloud-vision-discuss
I am getting 'permission error' when I use client libraries(PHP), but when I run curl request, its working. I am getting following error:

Fatal error: Uncaught Google\ApiCore\ApiException: { "message": "Permission denied.", "code": 7, "status": "PERMISSION_DENIED", "details": [] } thrown in D:\xampp\htdocs\GoogleVision\vendor\google\gax\src\ApiException.php on line 139

I am using following code:
-------------------------------------------------------------------------------------
$client = new ProductSearchClient();

    # a resource that represents Google Cloud Platform location.
    $locationPath = $client->locationName($projectId, $location);

    # create a product set with the product set specification in the region.
    $productSet = (new ProductSet())
        ->setDisplayName($productSetDisplayName);

    # the response is the product set with the `name` field populated.
    $response = $client->createProductSet($locationPath, $productSet, ['productSetId' => $productSetId]);
-----------------------------------------------------------------------------------------

And, I have already setup it for my main account - amit.da...@gmail.com, there its working, but when I tried to setup another account, its raising this error. I created a new account and setting up there, so that can hand over it to my client. Is it sdk need to reinstall for new setup?

Kevin

unread,
Mar 25, 2021, 6:20:07 AM3/25/21
to cloud-vision-discuss
Hello,

For both a curl request and a call with a library, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be set to the path of the key file [1, 2].

Please remind that Google Groups are reserved for general product discussion, StackOverflow for technical questions whereas Issue Tracker for product issues (unexpected behaviors) and feature requests [3].

Therefore, as both are issues and they seem related to configuration and code, if you continue to experience them, I suggest that you raise an issue on Stackoverflow or on the library's repository (PHP [4]).

On the other hand, if you believe that your config and code are correct and this is an unexpected behavior from one of our services, you can create an issue report on issue-tracker [5].

Best regards.
__________________
Reply all
Reply to author
Forward
0 new messages