15.2. Creating Authentication InformationTo use an instance of a Google AdWords API web service, the web service must be authenticated. The required authentication information is:
In an example Windows application, these values are entered by the user into TextBox controls named as shown in Table 15-1.
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 CampaignService.email( ); 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};
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 AdGroupService.email( ); 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 KeywordService.email( ); 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}; |