Closed n1sym closed 2 years ago
I used a proxy to authenticate with the Google Ad Manager API.
ad_manager_api.yml
:connection: :enable_gzip: false :proxy: http://user:password@proxy_hostname:8080
I was able to communicate with the API through the proxy, but after an hour or so, the API stopped responding to me.
/usr/local/bundle/gems/socksify-1.7.1/lib/socksify.rb:178:in `initialize': execution expired (Faraday::ConnectionFailed) /usr/local/bundle/gems/socksify-1.7.1/lib/socksify.rb:178:in `initialize': execution expired (Net::OpenTimeout)
Due to the fact that the expiration time was one hour (:expires_in: 3599) , I assumed that the refresh process had failed.
:expires_in: 3599
I checked the code. I noticed that fetch_access_token!uses a proxy, but refresh! does not.
fetch_access_token!
refresh!
https://github.com/googleads/google-api-ads-ruby/blob/bac3587a0c9570f5f002fee829b488d631306711/ads_common/lib/ads_common/auth/oauth2_handler.rb#L227
https://github.com/googleads/google-api-ads-ruby/blob/bac3587a0c9570f5f002fee829b488d631306711/ads_common/lib/ads_common/auth/oauth2_handler.rb#L103
I made a patch to use proxy in refresh! as well, and now I can communicate with the API.
If there is another way to solve this problem, I would appreciate it if you could let me know. Thank you.
Hi, hukurouo. Thank you for making this change. I need to test this thoroughly before accepting the pull request. I will have an update for you sometime this week.
background
I used a proxy to authenticate with the Google Ad Manager API.
ad_manager_api.yml
I was able to communicate with the API through the proxy, but after an hour or so, the API stopped responding to me.
Due to the fact that the expiration time was one hour (
:expires_in: 3599
) , I assumed that the refresh process had failed.I checked the code. I noticed that
fetch_access_token!
uses a proxy, butrefresh!
does not.https://github.com/googleads/google-api-ads-ruby/blob/bac3587a0c9570f5f002fee829b488d631306711/ads_common/lib/ads_common/auth/oauth2_handler.rb#L227
https://github.com/googleads/google-api-ads-ruby/blob/bac3587a0c9570f5f002fee829b488d631306711/ads_common/lib/ads_common/auth/oauth2_handler.rb#L103
I made a patch to use proxy in
refresh!
as well, and now I can communicate with the API.If there is another way to solve this problem, I would appreciate it if you could let me know. Thank you.