Skip to content

Commit

Permalink
Commit v24.7.1 to github
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherseeley committed Aug 2, 2019
1 parent ea07af2 commit 6c5229d
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 12 deletions.
14 changes: 12 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
24.7.1
======

AdWords:
- Added support for testing the client library against a local insecure server.

Ad Manager:
-

Common:
-

24.7.0
======

Expand All @@ -12,8 +24,6 @@
Common:
-



24.6.0
======

Expand Down
2 changes: 1 addition & 1 deletion examples/AdManager/CSharp/AdManager.Examples.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Ads.Common" Version="9.5.1" />
<PackageReference Include="Google.Dfp" Version="24.7.0" />
<PackageReference Include="Google.Dfp" Version="24.7.1" />
<PackageReference Include="System.ServiceModel.Http" Version="4.5.3" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Google.Ads.Common" Version="9.5.1" />
<PackageReference Include="Google.Dfp" Version="24.7.0" />
<PackageReference Include="Google.Dfp" Version="24.7.1" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
Expand Down
2 changes: 1 addition & 1 deletion examples/AdWords/CSharp/AdWords.Examples.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Ads.Common" Version="9.5.1" />
<PackageReference Include="Google.AdWords" Version="24.7.0" />
<PackageReference Include="Google.AdWords" Version="24.7.1" />
<PackageReference Include="System.ServiceModel.Http" Version="4.5.3" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Google.Ads.Common" Version="9.5.1" />
<PackageReference Include="Google.AdWords" Version="24.7.0" />
<PackageReference Include="Google.AdWords" Version="24.7.1" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
Expand Down
2 changes: 1 addition & 1 deletion examples/AdWords/Vb/AdWords.Examples.VB.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Ads.Common" Version="9.5.1" />
<PackageReference Include="Google.AdWords" Version="24.7.0" />
<PackageReference Include="Google.AdWords" Version="24.7.1" />
<PackageReference Include="System.ServiceModel.Http" Version="4.5.3" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/AdManager/AdManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Title>Google's Ad Manager API Dotnet Client Library</Title>
<PackageId>Google.Dfp</PackageId>
<Version>24.7.0</Version>
<Version>24.7.1</Version>
<Description>This library provides you with functionality to access the Google's Ad Manager API.</Description>
<PackageReleaseNotes>See https://github.com/googleads/googleads-dotnet-lib/blob/master/ChangeLog</PackageReleaseNotes>
<PackageTags>DFP Google</PackageTags>
Expand Down
2 changes: 1 addition & 1 deletion src/AdWords/AdWords.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Title>AdWords API Dotnet Client Library</Title>
<PackageId>Google.AdWords</PackageId>
<Version>24.7.0</Version>
<Version>24.7.1</Version>
<Description>This library provides you with functionality to access the AdWords API.</Description>
<PackageReleaseNotes>See https://github.com/googleads/googleads-dotnet-lib/blob/master/ChangeLog</PackageReleaseNotes>
<PackageTags>AdWords Google</PackageTags>
Expand Down
21 changes: 21 additions & 0 deletions src/AdWords/Lib/AdWordsAppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ public class AdWordsAppConfig : AppConfigBase
private ConfigSetting<string> adWordsApiServer =
new ConfigSetting<string>("AdWordsApi.Server", DEFAULT_ADWORDSAPI_SERVER);

/// <summary>
/// Authentication mode.
/// </summary>
/// <remarks>
/// This setting is only for testing purposes.
/// </remarks>
private ConfigSetting<AdWordsAuthorizationMethod> authorizationMethod =
new ConfigSetting<AdWordsAuthorizationMethod>("AuthorizationMethod",
AdWordsAuthorizationMethod.OAuth2);

/// <summary>
/// Flag to decide whether or not to skip report header.
/// </summary>
Expand Down Expand Up @@ -274,6 +284,16 @@ public string AdWordsApiServer
set => SetPropertyAndNotify(adWordsApiServer, value);
}

/// <summary>
/// Gets or sets the authorization method.
/// </summary>
/// <remarks>This setting is only for testing purposes.</remarks>
public AdWordsAuthorizationMethod AuthorizationMethod
{
get => authorizationMethod.Value;
set => SetPropertyAndNotify(authorizationMethod, value);
}

/// <summary>
/// Gets a useragent string that can be used with the library.
/// </summary>
Expand Down Expand Up @@ -336,6 +356,7 @@ protected override void ReadSettings(Dictionary<string, string> settings)

ReadSetting(settings, userAgent);
ReadSetting(settings, adWordsApiServer);
ReadSetting(settings, authorizationMethod);

// If there is an OAuth2 scope mentioned in App.config, this will be
// loaded by the base.ReadSettings() call above. If there isn't one, we will initialize
Expand Down
32 changes: 32 additions & 0 deletions src/AdWords/Lib/AdWordsAuthorizationMethod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2019, Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Google.Api.Ads.AdWords.Lib
{
/// <summary>
/// List of supported Authorization methods for AdWords API.
/// </summary>
public enum AdWordsAuthorizationMethod
{
/// <summary>
/// OAuth 2.0 draft 10 API.
/// </summary>
OAuth2,

/// <summary>
/// Insecure, for testing purposes.
/// </summary>
Insecure
}
}
21 changes: 19 additions & 2 deletions src/AdWords/Lib/AdWordsServiceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,18 @@ public override AdsClient CreateService(ServiceSignature signature, AdsUser user

// Create the binding for the service.
BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.Transport;

// If the server end point is HTTP, then don't use security. This is used for testing
// purposes only.
if (endpoint.Uri.Scheme == "http")
{
binding.Security.Mode = BasicHttpSecurityMode.None;
}
else
{
binding.Security.Mode = BasicHttpSecurityMode.Transport;
}

binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.MaxReceivedMessageSize = int.MaxValue;
binding.TextEncoding = Encoding.UTF8;
Expand All @@ -91,8 +102,14 @@ public override AdsClient CreateService(ServiceSignature signature, AdsUser user
(ServiceEndpoint) service.GetType().GetProperty("Endpoint").GetValue(service, null);

AdsServiceInspectorBehavior inspectorBehavior = new AdsServiceInspectorBehavior();
inspectorBehavior.Add(new OAuthClientMessageInspector(user.OAuthProvider));

// Add OAuth client message inspector only if the authorization method is OAuth2.
// In testing mode, the authorization method is set to Insecure.
if (awConfig.AuthorizationMethod == AdWordsAuthorizationMethod.OAuth2)
{
inspectorBehavior.Add(new OAuthClientMessageInspector(user.OAuthProvider));
}

RequestHeader clonedHeader = (RequestHeader) requestHeader.Clone();
clonedHeader.Version = awapiSignature.Version;
clonedHeader.GroupName = awapiSignature.GroupName;
Expand Down
6 changes: 5 additions & 1 deletion src/AdWords/Util/Reports/ReportUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,11 @@ private HttpWebRequest BuildRequest(string downloadUrl, string postBody, LogEntr
request.Headers.Add("clientCustomerId: " + config.ClientCustomerId);
request.ContentType = "application/x-www-form-urlencoded";

if (this.User.OAuthProvider != null)
// Set an authorization header only if the authorization mode is OAuth2. For testing
// purposes, the authorization method will be set to Insecure, and no authorization
// header will be sent.
if (config.AuthorizationMethod == AdWordsAuthorizationMethod.OAuth2 &&
this.User.OAuthProvider != null)
{
request.Headers["Authorization"] = this.User.OAuthProvider.GetAuthHeader();
}
Expand Down
3 changes: 3 additions & 0 deletions tests/AdWords/Lib/AdWordsAppConfigTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ internal class AdWordsAppConfigTests
{"MerchantCenter.AccountId", "123456"},
{"UserAgent", "TEST_USER_AGENT"},
{"AdWordsApi.Server", "TEST_API_SERVER"},
{"AuthorizationMethod", "Insecure"},
{"SkipReportHeader", "true"},
{"SkipReportSummary", "true"},
{"SkipColumnHeader", "false"},
Expand Down Expand Up @@ -114,6 +115,8 @@ public void TestReadSettings()

Assert.AreEqual(dictSettings["UserAgent"], config.UserAgent);
Assert.AreEqual(dictSettings["AdWordsApi.Server"], config.AdWordsApiServer);
Assert.AreEqual(dictSettings["AuthorizationMethod"],
config.AuthorizationMethod.ToString());
Assert.AreEqual(dictSettings["SkipReportHeader"],
config.SkipReportHeader.ToString().ToLower());
Assert.AreEqual(dictSettings["SkipReportSummary"],
Expand Down

0 comments on commit 6c5229d

Please sign in to comment.