Java Code Examples for com.google.api.ads.adwords.lib.client.AdWordsSession#Builder

The following examples show how to use com.google.api.ads.adwords.lib.client.AdWordsSession#Builder . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultipleClientReportDownloaderTest.java    From aw-reporting with Apache License 2.0 6 votes vote down vote up
/** Tests downloading reports. */
@Test
public void testDownloadReports() throws ReportProcessingException {

  AdWordsSession.Builder sessionBuilder =
    new AdWordsSession.Builder().withEndpoint("http://www.google.com")
      .withDeveloperToken("DeveloperToken")
      .withClientCustomerId("123")
      .withUserAgent("UserAgent")
      .withOAuth2Credential(new GoogleCredential.Builder().build());

  Set<Long> cids = ImmutableSet.of(1L, 2L, 3L, 4L, 5L);
  Collection<File> results =
      multipleClientReportDownloader.downloadReports(sessionBuilder, reportDefinition, cids);

  assertEquals(cids.size(), results.size());
}
 
Example 2
Source File: TestEntitiesGenerator.java    From adwords-alerting with Apache License 2.0 5 votes vote down vote up
public static AdWordsSession.Builder getTestAdWordsSessionBuilder() {
  return new AdWordsSession.Builder()
             .withEndpoint("http://www.google.com")
             .withDeveloperToken("DeveloperToken")
             .withClientCustomerId("123")
             .withUserAgent("UserAgent")
             .withOAuth2Credential(new GoogleCredential.Builder().build());
}
 
Example 3
Source File: InstalledOAuth2Authenticator.java    From aw-reporting with Apache License 2.0 4 votes vote down vote up
private AdWordsSession.Builder getSessionBuilderWithoutCredential() {
  return new AdWordsSession.Builder()
      .withUserAgent(userAgent)
      .withClientCustomerId(managerAccountId)
      .withDeveloperToken(developerToken);
}
 
Example 4
Source File: InstalledOAuth2Authenticator.java    From aw-reporting with Apache License 2.0 4 votes vote down vote up
private AdWordsSession.Builder authenticate(Credential credential) {
  return getSessionBuilderWithoutCredential().withOAuth2Credential(credential);
}
 
Example 5
Source File: InstalledOAuth2Authenticator.java    From aw-reporting with Apache License 2.0 4 votes vote down vote up
/**
 * Get an adwords session builder with the authentication info.
 */
@Override
public AdWordsSession.Builder authenticate() throws OAuthException {
  return getSessionBuilderWithoutCredential().withOAuth2Credential(getOAuth2Credential());
}
 
Example 6
Source File: Authenticator.java    From aw-reporting with Apache License 2.0 2 votes vote down vote up
/**
 * Authenticates the user against the API(s) depending on the OAuth scope and then returns an
 * {@link com.google.api.ads.adwords.lib.client.AdWordsSession.Builder}.
 *
 * @return an adwords session builder with the authentication info
 * @throws OAuthException error on the OAuth process
 */
AdWordsSession.Builder authenticate() throws OAuthException;
 
Example 7
Source File: AdWordsSessionUtil.java    From aw-reporting with Apache License 2.0 2 votes vote down vote up
/**
 * Build a new {@code ImmutableAdWordsSession} for the given cid.
 * @param sessionBuilder the adwords session builder
 * @param cid the client customer id (in long format)
 * @return an immutable adwords session for the specified cid
 */
public static ImmutableAdWordsSession buildImmutableSessionForCid(
    AdWordsSession.Builder sessionBuilder, Long cid) throws ValidationException {
  String cidStr = cid == null ? null : String.valueOf(cid);
  return buildImmutableSessionForCid(sessionBuilder, cidStr);
}
 
Example 8
Source File: AdWordsSessionUtil.java    From aw-reporting with Apache License 2.0 2 votes vote down vote up
/**
 * Build a new {@code ImmutableAdWordsSession} for the given cid.
 * @param sessionBuilder the adwords session builder
 * @param cid the client customer id (in string format)
 * @return an immutable adwords session for the specified cid
 */
public static ImmutableAdWordsSession buildImmutableSessionForCid(
    AdWordsSession.Builder sessionBuilder, String cid) throws ValidationException {
  return sessionBuilder.withClientCustomerId(cid).buildImmutable();
}