Section 15.2. Creating Authentication Information

15.2. Creating Authentication Information

To use an instance of a Google AdWords API web service, the web service must be authenticated. The required authentication information is:

  • Email address associated with an AdWords account

  • Password associated with the AdWords account

  • UserAgent (this can be any arbitrary string you'd like)

  • Developer Key

In an example Windows application, these values are entered by the user into TextBox controls named as shown in Table 15-1.

Table 15-1. AuthenticationYou need to provide a mechanism for the developer to enter information associated with the account (and the developer key)

Control name



Email address for AdWords account


Password for AdWords account


UserAgent string


Developer key

To add the email authentication value to the service object (instantiated from the CampaignService), create a new emailValue object within the service object:

     service.emailValue = new  );

Next, use the string object constructor to assign the value of the Text property of textEmail (entered by the user) to the new value:

     service.emailValue.Text = new String[] {txtEmail.Text};

You need to qualify emailValue (and other authentication values) with the name of the object that is being authenticated; otherwise, the reference would be ambiguous (it could refer to the emailValue associated with any AdWords web service object).

Create authentication value objects, and assign text based on user input, for the rest of the required authentication information in the CampaignService:

     service.passwordValue = new CampaignService.password(  );     service.passwordValue.Text = new String[] {txtPassword.Text};     service.useragentValue = new CampaignService.useragent(  );     service.useragentValue.Text = new String[] {txtUserAgent.Text};     service.tokenValue = new CampaignService.token(  );     service.tokenValue.Text = new String[] {txtSecret.Text};

Repeat the process for other AdWords API web services you'd like to authenticate, for example, the AdGroupService and KeywordService services:

     ag.emailValue = new  );     ag.emailValue.Text = new String[] {txtEmail.Text};     ag.passwordValue = new AdGroupService.password(  );     ag.passwordValue.Text = new String[] {txtPassword.Text};     ag.useragentValue = new AdGroupService.useragent(  );     ag.useragentValue.Text = new String[] {txtUserAgent.Text};     ag.tokenValue = new AdGroupService.token(  );     ag.tokenValue.Text = new String[] {txtSecret.Text};     ks.emailValue = new  );     ks.emailValue.Text = new String[] {txtEmail.Text};     ks.passwordValue = new KeywordService.password(  );     ks.passwordValue.Text = new String[] {txtPassword.Text};     ks.useragentValue = new KeywordService.useragent(  );     ks.useragentValue.Text = new String[] {txtUserAgent.Text};     ks.tokenValue = new KeywordService.token(  );     ks.tokenValue.Text = new String[] {txtSecret.Text};

Google Advertising Tools. Cashing in with AdSense, AdWords, and the Google APIs
Google Advertising Tools: Cashing in with Adsense, Adwords, and the Google APIs
ISBN: 0596101082
EAN: 2147483647
Year: 2004
Pages: 145
Authors: Harold Davis

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: