Service account access_token is None
See original GitHub issueHey,
I’m using the google-api-python-client==1.4.2
and oauth2client==1.5.1
, with service accounts in our internal SEO tool, which communicates with the webmaster tools API.
As I’m trying to batch fix crawl error samples, I get the following error:
Traceback (most recent call last):
File "/home/seodev/project/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/seodev/project/venv/lib/python3.4/site-packages/django/views/decorators/http.py", line 45, in inner
return func(request, *args, **kwargs)
File "/home/seodev/project/venv/lib/python3.4/site-packages/django/contrib/auth/decorators.py", line 22, in _wrapped_view
return view_func(request, *args, **kwargs)
File "./visualizer/seo/views.py", line 339, in json_sample_markfixed_many
result_json = cese_markfixed_many(request, id_list)
File "./visualizer/seo/utils.py", line 571, in cese_markfixed_many
exc_callback_item=exc_item, exc_callback_batch=exc_batch)
File "./collector_gapi/batch_handler.py", line 253, in run_batch
item_list, service_func, batch_parse_response, batch_request_dict)
File "./collector_gapi/batch_handler.py", line 94, in calculate_ideal_length
item_list, 1, service_func, callback, batch_request_dict)
File "./collector_gapi/batch_handler.py", line 72, in compile_batch
return batch, get_payload_size(batch)
File "./collector_gapi/batch_handler.py", line 42, in get_payload_size
body = batch._serialize_request(request)
File "/home/seodev/project/venv/lib/python3.4/site-packages/googleapiclient/http.py", line 1101, in _serialize_request
request.http.request.credentials.apply(headers)
File "/home/seodev/project/venv/lib/python3.4/site-packages/oauth2client/client.py", line 643, in apply
headers['Authorization'] = 'Bearer ' + self.access_token
TypeError: Can't convert 'NoneType' object to str implicitly
This exception doesn’t occur with google-api-python-client==1.4.1
, so 1.4.2 is definitely the culprit.
Could you please look into this and fix it?
Thx, László
Issue Analytics
- State:
- Created 8 years ago
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Service account API error when getting the access token
I created new project in the google console (https://console.cloud.google.com/) I enabled People API. I created needed Credentials - web client ...
Read more >Using OAuth 2.0 for Server to Server Applications | Authorization
A service account's credentials include a generated email address that is unique and at least one public/private key pair. If domain-wide delegation is...
Read more >Create short-lived credentials for a service account
Service accounts can use short-lived credentials to authenticate calls to Google Cloud APIs, other Google APIs, and non-Google APIs. Short-lived credentials ...
Read more >google.oauth2.service_account module
If this is None, the token is assumed to never expire. Open ID Connect ID Token-based service account credentials. These credentials are largely...
Read more >Creating a personal access token - GitHub Docs
Under Permissions, select which permissions to grant the token. Depending on which resource owner and which repository access you specified, there are ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Seeing this issue intermittently in 1.5.1.
The following workaround, which builds off of the previously reported workaround, resolves the issue for me so far:
As a workaround, I can force refresh the credentials prior to use: