我正在编写我的第一个 Google API Winforms 应用程序,但我无法弄清楚如何进行 API 调用。
此 google“入门”中的示例 documentation没有多大帮助。
我有一个客户端 ID 和密码,并已使用它们授权我的应用程序。
ClientSecrets cs = new ClientSecrets { ClientId = "<...>.apps.googleusercontent.com", ClientSecret = "<...>" };
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(cs, new[] { @"https://www.googleapis.com/auth/doubleclickbidmanager" }, "user",
System.Threading.CancellationToken.None, new Google.Apis.Util.Store.FileDataStore(@"C:\temp", true));
我现在想打电话this API 并查看其结果。
有人可以指导我如何去做吗?
最佳答案
安装 block 包 Install-Package Google.Apis.Doubleclickbidmanager.v1
以下代码应该适用于 Oauth2
string clientId = "ddd";
string clientSecret = "ddd";
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret }
, scopes
, "test"
, CancellationToken.None
, new FileDataStore(".",true)).Result;
var service = new DoubleClickBidManagerService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "xyz",
});
您的所有调用都应通过该服务进行
service.Lineitems.Downloadlineitems(body).Execute();
关于c# - 调用 DoubleClick Bid Manager API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32228727/