Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/content/v2/accounts/authinfo?alt=json returned "Insufficient Permission"> #751

Closed
castnow123 opened this issue Aug 23, 2019 · 10 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@castnow123
Copy link

Hi

I tried for several days to establish a Content API connection via Python for Google Shopping but I am getting permission denied. I have been advised to post the issue here as it seems to be library specific.

1- I set up a special directory to dumpy two json files. /home/castnow2019_gmail_com/shopping-samples/content. I dumped 2 JSONs files:
client-secrets.json merchant-info.json

2- Created a different directory that has Python code in /home/castnow2019/google/env/google-shopping/googleads-shopping-samples/python$

3- I ran pip install -r requirements.txt

4- I ran python -m shopping.content.products.list

but I received this error message:

File "/usr/local/lib/python2.7/dist-packages/googleapiclient/http.py", line 856, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/content/v2/accounts/authinfo?alt=json returned "Insufficient Permission">

how do I solve this issue?

@busunkim96
Copy link
Contributor

It sounds like the credentials you are using don't have sufficient permission. Would you be able to provide a code sample?

@castnow123
Copy link
Author

Sure..you mean Python sample code? it is here: https://github.com/googleads/googleads-shopping-samples/tree/master/python

The client-secret.json file gets created automatically by going to this link: https://console.developers.google.com/apis/credentials

@busunkim96
Copy link
Contributor

@castnow123 Which sample file specifically are you running?

It looks like you are using python 2.7. Do you know which version of the client library you are using?

In addition, please review the instructions here and here and confirm that you've followed the relevant steps for getting credentials.

@castnow123
Copy link
Author

@busunkim96
I am running list.py using this command python -m shopping.content.products.list

even if I run it using python3 it gives the error.

The client library is v2.1

I shared some screenshots of client-secrets.json after removing sensitive information.
this same service account is in the users section of my merchange center

Client secrets

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Aug 24, 2019
@busunkim96
Copy link
Contributor

Hmm, the client library is currently at version 1.7.11. Would you mind double-checking the library version?

If you installed using pip, this will give you the version number:

pip show google-api-python-client

There are instructions here on setting up authentication for the shopping samples. If you're using a service account, it looks like you should name the file service-account.json. client-secrets.json is for OAuth2 client credentials.

@busunkim96 busunkim96 added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. labels Aug 26, 2019
@castnow123
Copy link
Author

@busunkim96 Yes, I am using 1.7.11 I setup OAuth2 client ID as in the screenshot attached. I named the json to client-secrets.json.

but I still rceived this error. do you have skype so I can share my screen and show you? did you try to authenticate using python and you are not getting any errors?
client id

Using application default credentials.
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/castnow2019/google/env/google-shopping/googleads-shopping-samples/python/shopping/content/products/list.py", line 48, in
main(sys.argv)
File "/home/castnow2019/google/env/google-shopping/googleads-shopping-samples/python/shopping/content/products/list.py", line 29, in main
service, config, _ = common.init(argv, doc)
File "/home/castnow2019/google/env/google-shopping/googleads-shopping-samples/python/shopping/content/common.py", line 142, in init
retrieve_remaining_config_from_api(service, config)
File "/home/castnow2019/google/env/google-shopping/googleads-shopping-samples/python/shopping/content/common.py", line 179, in retrieve_remaining_config_from_api
authinfo = service.accounts().authinfo().execute()
File "/usr/local/lib/python3.5/dist-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/googleapiclient/http.py", line 856, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/content/v2/accounts/authinfo?alt=json returned "Insufficient Permission">

@busunkim96
Copy link
Contributor

And you said you've added the account to Merchant Center?

  1. Add the new service account as a user to your Merchant Center account. If you are a third party developer, you will need to have your client do this step for you.
    a. Go to your Merchant Center account.
    b. Go to the 'Users' list in the settings of your Merchant Center account.
    c. Click the + button, and use the service account ID as the email address for the new user.
    d. Specify User access and Email notifications, note that use of the Accounts service requires Admin access. Add service account user page screenshot.
    e. Click on the blue box to the left of Cancel. You will be returned to the list of users, and the service account ID should be listed with the chosen user role(s).
    f. Repeat the process for all other service accounts you want to add.
    g. View existing service account users by going to the Users tab. These will be users with an email address ending in 'gserviceaccount.com'.

I'm going to redirect you to the Content API folks who wrote the Python samples. I unfortunately can't help debug any further as I don't have access to the Merchant center platform.

@busunkim96
Copy link
Contributor

@castnow123 Please file your issue on the Google Content API for Shopping forum

@castnow123
Copy link
Author

yes I did all of the above when I wanted to authenticate using service account but that did not work too.

@busunkim96
Copy link
Contributor

@castnow123 Alright, please let the Content API for Shopping team know at their forum. They should be able to help debug the Authorization issue.

Apologies for not being able to be more of a help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants