Home:ALL Converter>JSONDecodeError for Google Search Console API sample script in Python

JSONDecodeError for Google Search Console API sample script in Python

Ask Time:2020-04-07T03:29:45         Author:santma

Json Formatter

I am trying to query my Google Search Console Data with the Search Console API. The script is here..

I am using OS and python3. I have the client_secret.py file in the same directory which I am 85% sure I authorized.

When I run it on a different computer, it works fine. I am sorry this explanation is not going to be great. I simply have no idea why the script doesn't work for me, but its working fine for my colleague. I suspect it has something to do with the haphazardness of my user/bin files. Anyway, if you can check out my query and error codes, maybe theres something more obvious. (I'm new).

This is my query. I've tried it in 129487321904 different variations:

$ python3 search_analytics_api_sample.py 'https://www.uselessthingstobuy.com/' '2020-02-10' '2020-03-10'

This are my errors:

Traceback (most recent call last):
  File "search_analytics_api_sample.py", line 191, in <module>
    main(sys.argv)
  File "search_analytics_api_sample.py", line 56, in main
    scope='https://www.googleapis.com/auth/webmasters.readonly')
  File "/Users/margaretsant/anaconda3/lib/python3.7/site-packages/googleapiclient/sample_tools.py", line 88, in init
    client_secrets, scope=scope, message=tools.message_if_missing(client_secrets)
  File "/Users/margaretsant/anaconda3/lib/python3.7/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Users/margaretsant/anaconda3/lib/python3.7/site-packages/oauth2client/client.py", line 2135, in flow_from_clientsecrets
    cache=cache)
  File "/Users/margaretsant/anaconda3/lib/python3.7/site-packages/oauth2client/clientsecrets.py", line 165, in loadfile
    return _loadfile(filename)
  File "/Users/margaretsant/anaconda3/lib/python3.7/site-packages/oauth2client/clientsecrets.py", line 122, in _loadfile
    obj = json.load(fp)
  File "/Users/margaretsant/anaconda3/lib/python3.7/json/__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/Users/margaretsant/anaconda3/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/Users/margaretsant/anaconda3/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/margaretsant/anaconda3/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I cannot for the life of me figure this one out. I tried installing all the necessary packages in a virtual environment, and I'm getting the same error.

I also have miniconda for no apparent reason. Could this be conflicting with anaconda in this case? I really have no idea what I'm doing, but I need to get this API to work for me. I haven't found anything in the crazy Google Developers documents, which are sooo confusing. And, I haven't found anyone with the same jsonDecoder error for this script. Thanks!

  • edit: I removed miniconda, still getting the same error

Author:santma,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/61067514/jsondecodeerror-for-google-search-console-api-sample-script-in-python
yy