Tuesday, 15 January 2013

java - Google Drive Api service accounts without Google Apps -



java - Google Drive Api service accounts without Google Apps -

i trying build connector google drive business relationship via google api oauth service account. using official gooogle client libraries java.

public static drive getdriveservice() throws generalsecurityexception, ioexception, urisyntaxexception { httptransport httptransport = googlenethttptransport.newtrustedtransport(); googlecredential credentials = new googlecredential.builder() .settransport(httptransport) .setjsonfactory(jacksonfactory.getdefaultinstance()) .setserviceaccountid(service_account_email) .setserviceaccountscopes(arrays.aslist(new string[]{drivescopes.drive})) .setserviceaccountprivatekeyfromp12file(new java.io.file(service_account_pkcs12_file_path)) .setserviceaccountuser(account_user) .build(); drive service = new drive.builder(httptransport, jacksonfactory.getdefaultinstance(), credentials) .sethttprequestinitializer(credentials).build(); homecoming service; }

it's pretty much basic sample docs. problem not work. after execution got nullpointerexception on json deserialization.

so debug code source code google libraries , found httprequest access token returns status code 401 , content null. used same approach google calendar api , works without problems.

could tell me doing wrong? or there way access files without user interaction? thanks

java google-drive-sdk google-oauth

No comments:

Post a Comment