googleads / googleads-dotnet-lib

Google Ad Manager SOAP API .NET client library
Apache License 2.0
108 stars 199 forks source link

AdWordsAppConfig Not Using configSource File #158

Closed ryanoshag closed 6 years ago

ryanoshag commented 6 years ago

After updating our client library recently, our app started failing with OAuth2 configuration errors. Further inspection revealed that configurations provided in a separate file and referenced using the configSource property in app.config (as detailed here) are no longer loaded (as of 23.0.0).

In previous versions, AppConfigBase used the ConfigurationManager.GetSection(sectionName) method to load the AdWordsApi section, which will pull in the configSource data automatically.

In versions >= 23.0.0, the new XmlDictionarySectionConfigurationProvider class is used to read in configuration data, and does not handle any configurations referenced through the configSource property.

AnashOommen commented 6 years ago

Could you temporarily put this in your App.config as a workaround? I'll provide a fix in an upcoming version.

ryanoshag commented 6 years ago

We can't really put it in our App.config, since we substitute out the AdWords configuration file based on the environment we're running in.

I was able to temporarily fix the issue on our end by loading the configuration in our code and passing a dictionary of config items to the AdWordsUser constructor.

This isn't ideal, however, so a fix would be much appreciated.

dvitel commented 6 years ago

I have similar problem: after updating to version 23, app crashes on call to ManagedCustomerService.get with ArgumentNullException:

Server stack trace: at Google.Api.Ads.Common.Lib.OAuth2ProviderBase.ValidateOAuth2Parameter(String propertyName, String propertyValue) at Google.Api.Ads.Common.Lib.OAuth2ProviderForApplications.RefreshAccessToken() at Google.Api.Ads.Common.Lib.OAuth2ProviderForApplications.RefreshAccessTokenIfExpiring() at Google.Api.Ads.Common.Lib.OAuth2ProviderBase.GetAuthHeader() at Google.Api.Ads.Common.Lib.OAuth2ClientMessageInspector.BeforeSendRequest(Message& request, IClientChannel channel) ... System.ArgumentNullException: Value cannot be null. Parameter name: Looks like your application is not configured to use OAuth2 properly. Required OAuth2 parameter RefreshToken is missing. You may run Common\Utils\OAuth2TokenGenerator.cs to generate a default OAuth2 configuration.

We tracked down that issue appears because AdWordsUser constructor did not read web.config AdWordsApi section. We have web.config alongside with exe.config of other projects. According to code from XmlDictionarySectionConfigurationSource.cs (Build method), web.config is ignored and exe.config is taken in such situation.

christopherseeley commented 6 years ago

Fixed in v23.3.0