google oauth - Error "Invalid token: Cannot parse referred token string" when trying to access to Picasaweb API with oAuth2 from Java -
when trying connect picasaweb api in java, i've got error:
com.google.gdata.util.serviceforbiddenexception: forbidden token invalid - invalid token: cannot parse referred token string @ com.google.gdata.client.http.httpgdatarequest.handleerrorresponse(httpgdatarequest.java:605) @ com.google.gdata.client.http.googlegdatarequest.handleerrorresponse(googlegdatarequest.java:564) @ com.google.gdata.client.http.httpgdatarequest.checkresponse(httpgdatarequest.java:560) @ com.google.gdata.client.http.httpgdatarequest.execute(httpgdatarequest.java:538) @ com.google.gdata.client.http.googlegdatarequest.execute(googlegdatarequest.java:536) @ com.google.gdata.client.service.insert(service.java:1409) @ com.google.gdata.client.googleservice.insert(googleservice.java:613) @ com.google.gdata.client.media.mediaservice.insert(mediaservice.java:380)
here code:
final string[] scopesarray = { "https://picasaweb.google.com/data/" }; final list scopes = arrays.aslist(scopesarray); final googlecredential credential = new googlecredential.builder() .settransport(new nethttptransport()) .setjsonfactory(new jacksonfactory()) .setserviceaccountid("xxx@developer.gserviceaccount.com") .setserviceaccountscopes(scopes) .setserviceaccountprivatekeyfromp12file(new file("key.p12")).build(); final picasawebservice picasaservice = new picasawebservice("toto"); picasaservice.setoauth2credentials(credential); picasaservice.insert(new url(feed_url), album);
i think somethig missing, how link between service account , picasa account made? tried had url in scope, https://picasaweb.google.com/data/entry/api/user/" + user_id or "https://picasaweb.google.com/data/feed/api/user/" + user_id, without success...
i want avoid 'user consent' dialog each time application access picasa album.
i didn't find examples of picasaweb api , oauth2, if have idea... thanks!
edit : found informations "delegating domain-wide authority service account" https://developers.google.com/identity/protocols/oauth2serviceaccount want setserviceaccountuser("user@example.com")
seems it's working google apps domains.
how link between service account , picasa account made?
there no link. service account , picasa account 2 different users far google concerned. (i'm guessing didn't explain use case) not want using service account.
treat picasa api , oauth 2 separate learning exercises. think of oauth stuff leads have access token, , picasa api thing poke access token into. try using oauth playground (https://developers.google.com/oauthplayground/) mock want achieve. teach need know oauth, , show http requests should like, can subsequently compare app.
Comments
Post a Comment