I need to migrate OAuth2

here's my code
PicasawebService service = new PicasawebService("everytrail");
  JacksonFactory jsonFactory = new JacksonFactory();
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
 GoogleCredential credential = new GoogleCredential.Builder()
 .setTransport(httpTransport)
        .setJsonFactory(jsonFactory)       
        .setServiceAccountId("[email protected]")
        .setServiceAccountPrivateKeyFromP12File(new 
File("src/main/resources/everytrail-picasaweb-f8adaf1642af.p12"))
       
 
.setServiceAccountScopes(Collections.singleton("https://picasaweb.google.com/data/";))
        .setServiceAccountUser("[email protected]")
        .build();

service.setOAuth2Credentials(credential);
 String token = credential.getAccessToken();
System.out.println("token: " + token);
 service.setOAuth2Credentials(credential);


token: null
version:com.google.gdata.client.photos.PicasawebService:2.0
Get Feed URL: 
https://picasaweb.google.com/data/feed/api/user/everytrail.co.kr?kind=album
com.google.gdata.util.ServiceForbiddenException: Forbidden
Token invalid - Invalid token: Cannot parse referred token string

at 
com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:605)
at 
com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
at 
com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
at 
com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
at 
com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
at com.google.gdata.client.Service.getFeed(Service.java:1135)
at com.google.gdata.client.Service.getFeed(Service.java:998)
at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:645)
at com.google.gdata.client.Service.getFeed(Service.java:1017)
at 
com.soundbread.everytrail.util.picasa.PicasawebClient.getFeed(PicasawebClient.java:254)
at 
com.soundbread.everytrail.util.picasa.PicasawebClient.getAlbums(PicasawebClient.java:114)
at 
com.soundbread.everytrail.util.picasa.PicasawebClient.main(PicasawebClient.java:329)

Is there anything I should do more ?



2015년 6월 1일 월요일 오후 4시 41분 53초 UTC+9, Mark Otway 님의 말:
>
> If it helps, I built a java OAuth2 implementation a couple of months back, 
> which works well and is reasonably self-contained. Feel free to have a look 
> at the code here: 
>
>
> https://github.com/Webreaper/PicasawebSync/tree/master/src/main/java/com/otway/picasasync/webclient
>
> On 1 Jun 2015, at 06:46, Gramps Gramps <[email protected] 
> <javascript:>> wrote:
>
> ---------- Forwarded message ----------
> From: 
> Date: Jun 1, 2015 07:45
> Subject: Re: [PWA API] Authenticating using OAuth 2 service account
> To: <[email protected] <javascript:>>
> Cc: 
>
> Hi Jim,
>
> Have you already tried using the library?
>
> Is there a "setOauth2..()" method available for the Picasawebservice class?
>
> Could you let me know the URL from where you got it?
>
> The google service APIs webpages are a mess, as far as usage of oAuth2 
> with its services...
>
> PWA is the worse....the ClientLogin and oAuth1 APIs are deprecated, but 
> somehow the jar files that I amusing still don't have the new setOAuth2 
> method for the any of the services...
>
> Cheers,
> Nuno
> On Jun 1, 2015 03:23, "Jim McCabe" <[email protected] <javascript:>> 
> wrote:
>
>> It turns out there is a newer version of gdata-core-1.0.jar which does 
>> support OAuth 2.  Not sure why the version stayed 1.0 though.
>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Google Picasa Web Albums API" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/google-picasa-data-api/9HHrZxkWMck/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/google-picasa-data-api
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Google Picasa Web Albums API" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>
> .
> To post to this group, send email to [email protected] 
> <javascript:>.
> Visit this group at http://groups.google.com/group/google-picasa-data-api.
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Picasa Web Albums API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-picasa-data-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to