Feature Request: Add Option to Cache Access Token
See original GitHub issueHi,
I’m trying to get a basic example working, but keep receiving the same error:
...
return _end_unary_response_blocking(state, call, True, None)
File "/Users/Louis/anaconda3/lib/python3.6/site-packages/grpc/_channel.py", line 466, in _end_unary_response_blocking
raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
status = StatusCode.UNAUTHENTICATED
details = "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project."
debug_error_string = "{"created":"@1537546478.122567000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1099,"grpc_message":"Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","grpc_status":16}"
The example code is shown below:
import google.ads.google_ads.client
customer_id = "123"
client = google.ads.google_ads.client.GoogleAdsClient.load_from_storage(
"google-ads.yaml")
ga_service = client.get_service("GoogleAdsService")
query = ('SELECT campaign.id FROM campaign ORDER BY campaign.id')
results = ga_service.search(customer_id, query)
try:
for row in results:
print('Campaign with ID %d and name "%s" was found.'
% (row.campaign.id.value, row.campaign.name.value))
except google.ads.google_ads.errors.GoogleAdsException as ex:
print('Request with ID "%s" failed with status "%s" and includes the '
'following errors:' % (ex.request_id, ex.error.code().name))
My credentials file google-ads.yaml
is set up as follows:
client_id: CLIENT_ID
client_secret: CLIENT_SECRET
refresh_token: REFRESH_TOKEN
developer_token: DEVELOPER_TOKEN
I assume the GoogleAdsClient
generates an access_token
from the refresh_token
? Am I misunderstanding how to send an authenticated request?
Thanks,
Louis
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Cache access tokens in a multitenant app - Microsoft Learn
Learn how to implement a custom token cache that derives from the Azure AD Authentication Library TokenCache class suitable for web apps.
Read more >Cache Authorized User Access Token Session
When the User Access feature is enabled the password is prompted when trying to access any of the protected sections it is applied...
Read more >Invoking OAuth and Caching Access Tokens - API Public Doc
For APIs secured with OAuth, Access Token is obtained from the token endpoint provided and passed on to the API with every request....
Read more >Caching tokens - Amazon Cognito - AWS Documentation
You can cache the access tokens so that your app only requests a new access token if a cached token is expired. Otherwise,...
Read more >OpenID Connect | Authentication - Google Developers
A refresh token provides your app continuous access to Google APIs while the user is not present in your application. To request a...
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 FreeTop 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
Top GitHub Comments
It could be useful for when performing many operations/reporting queries with many different clients (i.e. different customer ids), thus meaning it doesn’t have to refresh the access token for these client instances every time if it’s before the cached token expiry date 👍
This issue is on hold pending a decision to make this functionality available for all supported client libraries.