Google Analytics V3 - Authentication Java -


this code access google analytics api upload audiences. when tried execute getting "401 : login required".i have provided correct client id , client secret. there other object need populate in googlecredential ? missing ?

public class testgoogleanalytics {   private static final string application_name = "calling analytics";   private static final jsonfactory json_factory = gsonfactory.getdefaultinstance();  public static void main(string[] args) throws ioexception, generalsecurityexception{ try {   file file = new file("/home/hariprasath/test.csv");   system.out.println(file.canwrite());   analytics analytics = createanalytics();   inputstreamcontent mediacontent = new inputstreamcontent("application/octet-stream",     new fileinputstream(file));   mediacontent.setlength(file.length());   system.out.println("test" + file.length());   uploads uploads = analytics.management().uploads().list("accountid",       "webpropertyid", "customdatasourceid").execute(); } catch (googlejsonresponseexception e) {   system.err.println("there service error: "       + e.getdetails().getcode() + " : "       + e.getdetails().getmessage()); }  }   private static analytics createanalytics() throws generalsecurityexception, ioexception{ httptransport httptransport = googlenethttptransport.newtrustedtransport(); httpexecuteinterceptor interseptor; googlecredential credential = new googlecredential.builder()     .settransport(httptransport)     .setjsonfactory(json_factory)     .setclientsecrets("clientid", "clientsecret")     .set     .build(); // construct analytics service object. return new analytics.builder(httptransport, json_factory, credential)     .setapplicationname(application_name).build(); 

}

}


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -