2

I am writing my first Google APIs Winforms application and I'm unable to figure out how to make an API call.

The example in this google "get started" documentation is not helping a lot.

I have a Client ID and secret and have authorized my app using these.

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));

I now want to call this API and see its results.

Can someone give me pointers on how do I go about it?

T.S.
  • 18,195
  • 11
  • 58
  • 78
ViV
  • 1,998
  • 8
  • 27
  • 54

1 Answers1

2

Install the nugget package Install-Package Google.Apis.Doubleclickbidmanager.v1

The following code should work for 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",    
       });

All your calls should go though the service

service.Lineitems.Downloadlineitems(body).Execute();
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • Hi @DalmTo, thanks for your answer. Can you please point me to some documentation of the DoubleClickBidManagerService and its APIs, so that I can really understand how do I make all the API calls I need. Or If you have some sample code, which you can share, that does basic upload and download of lineitems, that would be great!! Thanks a lot... – ViV Sep 01 '15 at 14:49
  • 1
    I can't really I don't know of any and I don't have a double click account so can't write you a tutorial sorry. – Linda Lawton - DaImTo Sep 01 '15 at 14:52
  • No Problem.. I really appreciate your help. – ViV Sep 01 '15 at 15:52