Skip to content

Commit

Permalink
Changes for Google Ads API v0_3. (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnashOommen authored Sep 5, 2018
1 parent 49784c6 commit bfe1abd
Show file tree
Hide file tree
Showing 234 changed files with 45,041 additions and 18,824 deletions.
13 changes: 13 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
0.4.0
=====

- Added support for Google Ads API v0.3.0. See release notes:
https://developers.google.com/google-ads/api/docs/release-notes#030_2018-08-29.
- New code examples were added to illustrate shared keyword sets, campaign groups and campaign
bid modifiers.
- Added support for logging of API requests and responses.
- Reformatted the code to match Microsoft's C# coding conventions:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions
- Updated nuget package references for Grpc.Core and Google.Api.Gax.Grpc to the latest version.
- Refactored service creation logic.

0.3.0
=====

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Apis.Auth" Version="1.34.0" />
<PackageReference Include="Google.Apis.Auth" Version="1.35.1" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Web" />
Expand Down
112 changes: 59 additions & 53 deletions examples/Authentication/AuthenticateInStandaloneApplication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,66 +19,72 @@
using System.Threading;
using System.Threading.Tasks;

namespace Google.Ads.GoogleAds.Examples {

/// <summary>
/// Entry point for the application.
/// </summary>
internal class Program {

namespace Google.Ads.GoogleAds.Examples
{
/// <summary>
/// The Google Ads API scope.
/// Entry point for the application.
/// </summary>
private const string GOOGLE_ADS_API_SCOPE = "https://www.googleapis.com/auth/adwords";
internal class Program
{
/// <summary>
/// The Google Ads API scope.
/// </summary>
private const string GOOGLE_ADS_API_SCOPE = "https://www.googleapis.com/auth/adwords";

/// <summary>
/// The main entry point for the application.
/// </summary>
public static void Main(string[] args) {
Console.WriteLine("This application generates an OAuth2 refresh token for use with " +
"the Google Ads API .NET client library. To use this application\n" +
"1) Follow the instructions on " +
"https://developers.google.com/adwords/api/docs/guides/authentication#create_a_client_id_and_client_secret " +
"to generate a new client ID and secret.\n" + "2) Enter the client ID and client Secret " +
"when prompted.\n" +
"3) Once the output is generated, copy its contents into your App.config file.\n\n");
/// <summary>
/// The main entry point for the application.
/// </summary>
public static void Main(string[] args)
{
Console.WriteLine("This application generates an OAuth2 refresh token for use with " +
"the Google Ads API .NET client library. To use this application\n" +
"1) Follow the instructions on " +
"https://developers.google.com/adwords/api/docs/guides/authentication#create_a_client_id_and_client_secret " +
"to generate a new client ID and secret.\n" + "2) Enter the client ID and client Secret " +
"when prompted.\n" +
"3) Once the output is generated, copy its contents into your App.config file.\n\n");

// Accept the client ID from user.
Console.Write("Enter the client ID: ");
string clientId = Console.ReadLine();
// Accept the client ID from user.
Console.Write("Enter the client ID: ");
string clientId = Console.ReadLine();

// Accept the client ID from user.
Console.Write("Enter the client secret: ");
string clientSecret = Console.ReadLine();
// Accept the client ID from user.
Console.Write("Enter the client secret: ");
string clientSecret = Console.ReadLine();

// Load the JSON secrets.
ClientSecrets secrets = new ClientSecrets() {
ClientId = clientId,
ClientSecret = clientSecret
};
// Load the JSON secrets.
ClientSecrets secrets = new ClientSecrets()
{
ClientId = clientId,
ClientSecret = clientSecret
};

try {
// Authorize the user using installed application flow.
Task<UserCredential> task = GoogleWebAuthorizationBroker.AuthorizeAsync(
secrets,
new string[] { GOOGLE_ADS_API_SCOPE },
String.Empty,
CancellationToken.None,
new NullDataStore()
);
UserCredential credential = task.Result;
try
{
// Authorize the user using installed application flow.
Task<UserCredential> task = GoogleWebAuthorizationBroker.AuthorizeAsync(
secrets,
new string[] { GOOGLE_ADS_API_SCOPE },
String.Empty,
CancellationToken.None,
new NullDataStore()
);
UserCredential credential = task.Result;

Console.WriteLine("\nCopy the following content into your App.config file.\n\n" +
$"<add key = 'OAuth2Mode' value = 'APPLICATION' />\n" +
$"<add key = 'OAuth2ClientId' value = '{clientId}' />\n" +
$"<add key = 'OAuth2ClientSecret' value = '{clientSecret}' />\n" +
$"<add key = 'OAuth2RefreshToken' value = '{credential.Token.RefreshToken}' />\n");
Console.WriteLine("\nCopy the following content into your App.config file.\n\n" +
$"<add key = 'OAuth2Mode' value = 'APPLICATION' />\n" +
$"<add key = 'OAuth2ClientId' value = '{clientId}' />\n" +
$"<add key = 'OAuth2ClientSecret' value = '{clientSecret}' />\n" +
$"<add key = 'OAuth2RefreshToken' value = " +
$"'{credential.Token.RefreshToken}' />\n");

Console.WriteLine("Press <Enter> to continue...");
Console.ReadLine();
} catch (AggregateException) {
Console.WriteLine("An error occured while authorizing the user.");
}
Console.WriteLine("Press <Enter> to continue...");
Console.ReadLine();
}
catch (AggregateException)
{
Console.WriteLine("An error occured while authorizing the user.");
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.7\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.7\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\..\..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props" Condition="Exists('..\..\..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props')" />
<Import Project="..\..\..\packages\Microsoft.Net.Compilers.2.9.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\..\..\packages\Microsoft.Net.Compilers.2.9.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -48,44 +48,44 @@
<ProjectReference Condition="Exists('..\..\..\src\Google.Ads.GoogleAds.csproj')" Include="..\..\..\src\Google.Ads.GoogleAds.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Google.Ads.GoogleAds, Version=0.3.0.0, Culture=neutral, PublicKeyToken=52807268f2b614dc, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Ads.GoogleAds.0.3.0\lib\net452\Google.Ads.GoogleAds.dll</HintPath>
<Reference Include="Google.Ads.GoogleAds, Version=0.4.0.0, Culture=neutral, PublicKeyToken=52807268f2b614dc, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Ads.GoogleAds.0.4.0\lib\net452\Google.Ads.GoogleAds.dll</HintPath>
</Reference>
<Reference Include="Google.Api.CommonProtos, Version=1.2.0.0, Culture=neutral, PublicKeyToken=3ec5ea7f18953e47, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Api.CommonProtos.1.2.0\lib\net45\Google.Api.CommonProtos.dll</HintPath>
<Reference Include="Google.Api.CommonProtos, Version=1.3.0.0, Culture=neutral, PublicKeyToken=3ec5ea7f18953e47, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Api.CommonProtos.1.3.0\lib\net45\Google.Api.CommonProtos.dll</HintPath>
</Reference>
<Reference Include="Google.Api.Gax, Version=2.4.0.0, Culture=neutral, PublicKeyToken=3ec5ea7f18953e47, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Api.Gax.2.4.0-beta02\lib\net45\Google.Api.Gax.dll</HintPath>
<Reference Include="Google.Api.Gax, Version=2.5.0.0, Culture=neutral, PublicKeyToken=3ec5ea7f18953e47, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Api.Gax.2.5.0\lib\net45\Google.Api.Gax.dll</HintPath>
</Reference>
<Reference Include="Google.Api.Gax.Grpc, Version=2.4.0.0, Culture=neutral, PublicKeyToken=3ec5ea7f18953e47, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Api.Gax.Grpc.2.4.0-beta02\lib\net45\Google.Api.Gax.Grpc.dll</HintPath>
<Reference Include="Google.Api.Gax.Grpc, Version=2.5.0.0, Culture=neutral, PublicKeyToken=3ec5ea7f18953e47, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Api.Gax.Grpc.2.5.0\lib\net45\Google.Api.Gax.Grpc.dll</HintPath>
</Reference>
<Reference Include="Google.Apis, Version=1.33.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Apis.1.33.0\lib\net45\Google.Apis.dll</HintPath>
<Reference Include="Google.Apis, Version=1.35.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Apis.1.35.1\lib\net45\Google.Apis.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.Auth, Version=1.33.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Apis.Auth.1.33.0\lib\net45\Google.Apis.Auth.dll</HintPath>
<Reference Include="Google.Apis.Auth, Version=1.35.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Apis.Auth.1.35.1\lib\net45\Google.Apis.Auth.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.Auth.PlatformServices, Version=1.33.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Apis.Auth.1.33.0\lib\net45\Google.Apis.Auth.PlatformServices.dll</HintPath>
<Reference Include="Google.Apis.Auth.PlatformServices, Version=1.35.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Apis.Auth.1.35.1\lib\net45\Google.Apis.Auth.PlatformServices.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.Core, Version=1.33.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Apis.Core.1.33.0\lib\net45\Google.Apis.Core.dll</HintPath>
<Reference Include="Google.Apis.Core, Version=1.35.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Apis.Core.1.35.1\lib\net45\Google.Apis.Core.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.PlatformServices, Version=1.33.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Apis.1.33.0\lib\net45\Google.Apis.PlatformServices.dll</HintPath>
<Reference Include="Google.Apis.PlatformServices, Version=1.35.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Apis.1.35.1\lib\net45\Google.Apis.PlatformServices.dll</HintPath>
</Reference>
<Reference Include="Google.Protobuf, Version=3.5.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Protobuf.3.5.1\lib\net45\Google.Protobuf.dll</HintPath>
<Reference Include="Google.Protobuf, Version=3.6.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="Grpc.Auth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Grpc.Auth.1.10.0\lib\net45\Grpc.Auth.dll</HintPath>
<HintPath>..\..\..\packages\Grpc.Auth.1.14.1\lib\net45\Grpc.Auth.dll</HintPath>
</Reference>
<Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Grpc.Core.1.10.0\lib\net45\Grpc.Core.dll</HintPath>
<HintPath>..\..\..\packages\Grpc.Core.1.14.1\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.7\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Extensions.Configuration, Version=1.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
Expand All @@ -97,18 +97,18 @@
<Reference Include="Microsoft.Extensions.Primitives, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Extensions.Primitives.1.1.1\lib\netstandard1.0\Microsoft.Extensions.Primitives.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Interactive.Async, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath>
<Reference Include="System.Interactive.Async, Version=3.2.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Interactive.Async.3.2.0\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Runtime.CompilerServices.Unsafe.4.3.0\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.1\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
Expand Down Expand Up @@ -187,11 +187,11 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.7\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.7\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
<Error Condition="!Exists('..\..\..\packages\Grpc.Core.1.10.0\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Grpc.Core.1.10.0\build\net45\Grpc.Core.targets'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.Net.Compilers.2.9.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Net.Compilers.2.9.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\..\..\packages\Grpc.Core.1.14.1\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Grpc.Core.1.14.1\build\net45\Grpc.Core.targets'))" />
</Target>
<Import Project="..\..\..\packages\Grpc.Core.1.10.0\build\net45\Grpc.Core.targets" Condition="Exists('..\..\..\packages\Grpc.Core.1.10.0\build\net45\Grpc.Core.targets')" />
<Import Project="..\..\..\packages\Grpc.Core.1.14.1\build\net45\Grpc.Core.targets" Condition="Exists('..\..\..\packages\Grpc.Core.1.14.1\build\net45\Grpc.Core.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
Loading

0 comments on commit bfe1abd

Please sign in to comment.