You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Request you to share the GAM360 complete document to access through JAVA API. Complete Code :
// Import libraries
import com.google.api.client.auth.oauth2.Credential;
// Replace with your values (instructions in comments)
private static final String CLIENT_ID = ""
private static final String CLIENT_SECRET = ""
private static final String REDIRECT_URI = ""
private static final String APPLICATION_NAME = ""
private static final String NETWORK_ID = ""
public static void main(String[] args) throws Exception {
// Authorization (refer to Google Ads documentation for detailed setup)
final Credential credential = authorize(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
// Create Dfareporting service object
final NetHttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
final JacksonFactory jsonFactory = JacksonFactory.getDefaultInstance();
final Dfareporting dfareporting = new Dfareporting.Builder(httpTransport, jsonFactory, credential)
.setApplicationName(APPLICATION_NAME)
.build();
// List campaigns
List<Campaign> campaigns = listCampaigns(dfareporting, NETWORK_ID);
System.out.println("Retrieved Campaigns:");
for (Campaign campaign : campaigns) {
System.out.println(" - ID: " + campaign.getId() + ", Name: " + campaign.getName());
}
}
public static Credential authorize(final String CLIENT_ID, final String CLIENT_SECRET, final String REDIRECT_URI) throws Exception {
// Replace with your actual paths
final File DATA_STORE_DIR = new File(System.getProperty("user.home"), ".credentials/dfareporting");
final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
final JacksonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
final DataStoreFactory DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR);
// Build flow and trigger user authorization request.
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, CLIENT_ID, CLIENT_SECRET, DfareportingScopes.all())
.setDataStoreFactory(DATA_STORE_FACTORY)
.setAccessType("offline")
.build();
**LocalServerReceiver** receiver = new **LocalServerReceiver**.Builder().setPort(8888).build();
return new **AuthorizationCodeInstalledApp**(flow, receiver).authorize("user");
}
public static List listCampaigns(final Dfareporting dfareporting, final String network)
Regards,
Usman
The text was updated successfully, but these errors were encountered:
Hi Team,
Account Name : [email protected]
I am able to setup the client for GAM 360. (JAVA API)
However, I am unable to load dependencies for JAVA API related to GAM360 Campaigns.
As suggested by your online document dependency added is :
com.google.api.client
google-api-client-auth-oauth2
1.2.3-alpha
However, Getting errors:
Cannot resolve symbol 'LocalServerReceiver'
Cannot resolve symbol 'AuthorizationCodeInstalledApp'
Imports not loaded: import com.google.api.services.dfareporting.model.CampaignsListRequest;
import com.google.api.services.dfareporting.model.Pagination;
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
Request you to share the GAM360 complete document to access through JAVA API. Complete Code :
// Import libraries
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.util.store.DataStoreFactory;
import com.google.api.client.util.store.FileDataStoreFactory;
import com.google.api.services.dfareporting.Dfareporting;
import com.google.api.services.dfareporting.DfareportingScopes;
import com.google.api.services.dfareporting.model.Campaign;
import com.google.api.services.dfareporting.model.CampaignsListRequest;
import com.google.api.services.dfareporting.model.Pagination;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class GetCampaigns {
// Replace with your values (instructions in comments)
private static final String CLIENT_ID = ""
private static final String CLIENT_SECRET = ""
private static final String REDIRECT_URI = ""
private static final String APPLICATION_NAME = ""
private static final String NETWORK_ID = ""
public static void main(String[] args) throws Exception {
}
public static Credential authorize(final String CLIENT_ID, final String CLIENT_SECRET, final String REDIRECT_URI) throws Exception {
// Replace with your actual paths
final File DATA_STORE_DIR = new File(System.getProperty("user.home"), ".credentials/dfareporting");
}
public static List listCampaigns(final Dfareporting dfareporting, final String network)
Regards,
Usman
The text was updated successfully, but these errors were encountered: