Unable to call APIs on our Company Proxy, how to get access to APIs on proxy

41 views
Skip to first unread message

Vijaya Salokhe

unread,
Dec 10, 2021, 2:52:31 AM12/10/21
to Google Ad Manager API Forum
Unable to call APIs on our Company Proxy, how to get access to APIs on proxy

Ad Manager API Forum Advisor

unread,
Dec 10, 2021, 4:19:09 AM12/10/21
to vijaya....@vimncontractor.com, google-doubleclick...@googlegroups.com

Hi Vijaya,

 

Thanks for reaching out to us.

 

I would recommend checking out our guide to Authentication for more information on how to properly access the API. However, if by chance that this is irrelevant to you, can I ask for you to provide more details to your concern so that I may further investigate this?

 

Regards,

 

 

Google Logo
Yasmin Gabrielle Padua
Ad Manager API Team
 


ref:_00D1U1174p._5004Q2SdqmT:ref

Vijaya Salokhe

unread,
Dec 10, 2021, 4:37:50 AM12/10/21
to Google Ad Manager API Forum
Hello,

I am using Web Application OAuth authentication method. I can call APIs successfully if I don't use Company Proxy, but to run project on Production, I need to use company proxy. If I set Proxy, it throws error: Failed to refresh access token. Do we need to provide proxy details anywhere in config to allow access to APIs or I need to get access to GAM APIs on proxy? If I need to get access on proxy, do I need to get it for URL: https://www.googleapis.com/auth/dfp which is a scope for GAM API or any other URL?
Could you please guide how to get access to GAM APIs on any external/company proxy.


Thanks..

Ad Manager API Forum Advisor

unread,
Dec 13, 2021, 4:24:58 AM12/13/21
to vijaya....@vimncontractor.com, google-doubleclick...@googlegroups.com

Hi Vijaya,

 

Can you kindly confirm if you're using our client libraries? Can I also request for a stack trace of the error so that we may further investigate?

 

Thanks,

Vijaya Salokhe

unread,
Dec 15, 2021, 9:06:52 AM12/15/21
to Google Ad Manager API Forum

Hello,

I am using .Net library. PFB the exception details

Stack Trace:

  at Newtonsoft.Json.JsonTextReader.ParseValue() in /_/Src/Newtonsoft.Json/JsonTextReader.cs:line 1772
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter) in /_/Src/Newtonsoft.Json/JsonReader.cs:line 1195
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 149
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) in /_/Src/Newtonsoft.Json/JsonSerializer.cs:line 907
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) in /_/Src/Newtonsoft.Json/JsonConvert.cs:line 828
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) in /_/Src/Newtonsoft.Json/JsonConvert.cs:line 786
   at Google.Apis.Json.NewtonsoftJsonSerializer.Deserialize[T](String input) in C:\Apiary\2018-10-17.13-21-41\Src\Support\Google.Apis.Core\Json\NewtonsoftJsonSerializer.cs:line 186
   at Google.Apis.Auth.OAuth2.Requests.TokenRequestExtenstions.ExecuteAsync(TokenRequest request, HttpClient httpClient, String tokenServerUrl, CancellationToken taskCancellationToken, IClock clock) in C:\Apiary\2018-10-17.13-21-41\Src\Support\Google.Apis.Auth\OAuth2\Requests\TokenRequestExtenstions.cs:line 52
   at Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.FetchTokenAsync(String userId, TokenRequest request, CancellationToken taskCancellationToken) in C:\Apiary\2018-10-17.13-21-41\Src\Support\Google.Apis.Auth\OAuth2\Flows\AuthorizationCodeFlow.cs:line 315
   at Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.RefreshTokenAsync(String userId, String refreshToken, CancellationToken taskCancellationToken) in C:\Apiary\2018-10-17.13-21-41\Src\Support\Google.Apis.Auth\OAuth2\Flows\AuthorizationCodeFlow.cs:line 264
   at Google.Apis.Auth.OAuth2.UserCredential.RefreshTokenAsync(CancellationToken taskCancellationToken) in C:\Apiary\2018-10-17.13-21-41\Src\Support\Google.Apis.Auth\OAuth2\UserCredential.cs:line 133
   at Google.Apis.Auth.OAuth2.TokenRefreshManager.RefreshTokenAsync() in C:\Apiary\2018-10-17.13-21-41\Src\Support\Google.Apis.Auth\OAuth2\TokenRefreshManager.cs:line 129
   at Google.Apis.Auth.OAuth2.TokenRefreshManager.GetAccessTokenForRequestAsync(CancellationToken cancellationToken) in C:\Apiary\2018-10-17.13-21-41\Src\Support\Google.Apis.Auth\OAuth2\TokenRefreshManager.cs:line 114

Inner Exception:
Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

Exception:
Failed to refresh access token. See inner exception for details.

Vijaya Salokhe

unread,
Dec 16, 2021, 5:23:56 AM12/16/21
to Google Ad Manager API Forum
Hello,

I added below code to set client proxy and now I am getting error as below:

 System.Net.WebProxy myProxy = new System.Net.WebProxy("http://proxy.xxxxx.com:xxxx/", true);
            // potentially, setup credentials on the proxy here
            myProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
            myProxy.UseDefaultCredentials = true;
            config.Proxy = myProxy;


Now I am getting this error: 
The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--//////////////////////////////////////////////////////////////////////////////  Copyright (c) 1996 - 2010, Websense, Inc.  All Rights Reserved//  See WebsenseCopyright.txt for copyright information/////////////////////////////////////////////////////////////////////////////--><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><title>Access to this site is blocked</title></head><body><!--[if lt IE 7]> <div style="width: 725px;"> <![endif]--><div style="border: 1px solid #285EA6;width: 95%; max-width: 1200px; overflow: hidden; margin-left: 10px; background-color: #EEF2F7;"><iframe src="http://CompanyProxyIP:15871/cgi-bin/block_message.cgi?ws-session=-820020194" title="test" name="ws_block" frameborder="0" scrolling="auto" style="width:100%; height: 11.5em;"></iframe><iframe src="http:// CompanyProxyIP  :15871/cgi-bin/blockOptions.c'.

Could you please let me know which URL is getting blocked here so that I can raise access request for that URL?

Ad Manager API Forum Advisor

unread,
Dec 17, 2021, 10:57:43 AM12/17/21
to vijaya....@vimncontractor.com, google-doubleclick...@googlegroups.com

Hello Vijaya,

 

Thank you for providing the requested information. I'm a colleague of Yasmin from the Ad Manager API team.

 

I'm afraid that our team is unable to provide support for proxy configurations. I suggest you check the firewall and proxy configurations on your end. Alternatively, you may also post your concern in the .NET client library's Issues page to check if the client library's authors/maintainers can assist you on this. If you want, you may also try to use our other client libraries with existing documentation on proxy configuration (e.g. Java).

 

Regards,

Google Logo
Kevin Gil Soriano
Ad Manager API Team
 


ref:_00D1U1174p._5004Q2SdqmT:ref
Reply all
Reply to author
Forward
0 new messages