java - No spreadsheets found when using AppIdentityService to authenticate -
i can authenticate app engine app using appidentityservice
. when perform spreadsheetservice.getentries
receive no entries.
here's code:
spreadsheetservice service = new spreadsheetservice("spreadsheet editing"); string[] scopesarray = { "https://spreadsheets.google.com/feeds" }; final list scopes = arrays.aslist(scopesarray); appidentityservice appidentity = appidentityservicefactory.getappidentityservice(); appidentityservice.getaccesstokenresult accesstoken = appidentity.getaccesstoken(scopes); credential creds = new credential(bearertoken.authorizationheaderaccessmethod()); creds.setaccesstoken(accesstoken.getaccesstoken()); service.setoauth2credentials(creds); spreadsheetfeed feed = service.getfeed(new url("https://spreadsheets.google.com/feeds/spreadsheets/private/full"), spreadsheetfeed.class); list spreadsheets = feed.getentries();
at point, spreadsheets empty list.
i have shared spreadsheet app entering service account email in spreadsheet's "share" box - email in form: xxx@developer.gserviceaccount.com
.
have misunderstood permissions here? "sharing" spreadsheet service account not enough make service account "see" spreadsheet?
at moment believe appidentity
not supported when updating using sheets api google app engine.
it appears possible authenticate, list of spreadsheetentry
s empty.
instead, use service account google app engine specifying credentials in googlecredential
instance:
googlecredential creds = new googlecredential.builder() .settransport(googlenethttptransport.newtrustedtransport()) .setjsonfactory(jacksonfactory.getdefaultinstance()) .setserviceaccountid(serviceaccountemailaddress) .setserviceaccountprivatekeyfromp12file(p12filefromcredentials) .setserviceaccountscopes(scopes) .build(); service.setoauth2credentials(creds);
Comments
Post a Comment