Hi!
I was wondering if you could help me...
I did all the "dancing" around the tokens and have created a
GoogleCredential object with the Access Token retrieved from the Google
Authentication url.
My goal is then to interact with Picasa such as I could upload an image and
retrieve the direct URL.
However, after creating the object:
PicasawebService picasaWebSvc = new PicasawebService("GOOGLE_APP_NAME");
my library does not have "setOAuth2Credentials" in the list of available
methods, I can only find this one:
picasaWebSvc.setOAuthCredentials(parameters, signer);
Is there a newer library version or something? where did you get the
library which allows you to create a service and set the OAuth2 credential
object?
Many thanks for your help,
Gizmo
Em domingo, 12 de outubro de 2014 21:51:49 UTC+2, Stijn Haezebrouck
escreveu:
>
> I am also having problems.
> I try to use Java. First, I registered, as I should, a service account.
> Downloaded a private key in a keystore formatted as PKCS12.
>
> This is the code I am using:
>
> @Test
> public void authenticate() throws Exception {
> KeyStore keyStore = KeyStore.getInstance("PKCS12");
> keyStore.load(getPKCS12(), "notasecret".toCharArray());
> PrivateKey key =
> (PrivateKey)keyStore.getKey("privatekey","notasecret".toCharArray());
> System.out.println(key.getClass().getName());
>
> GoogleCredential credential = new GoogleCredential.Builder()
> .setTransport(new NetHttpTransport())
> .setJsonFactory(JacksonFactory.getDefaultInstance())
> .setServiceAccountId(SERVICE_ACCOUNT_CLIENT_ID)
> .setServiceAccountPrivateKey(key)
> .setServiceAccountScopes(singleton("
> http://picasaweb.google.com/data/")) //correct scope
> according to forums
> .build();
>
> PicasawebService myService = new
> PicasawebService("triptrap-foto-feed");
> myService.setOAuth2Credentials(credential);
> URL feedUrl = new URL("
> https://picasaweb.google.com/data/feed/api/user/6061450663921646098?kind=album
> ");
>
> UserFeed myUserFeed = myService.getFeed(feedUrl, UserFeed.class);
> }
>
> In this code, getPKCS12() is a method returning an InputStream to the
> pkkcs12 file.
> The id in the feedUrl, 6061450663921646098, is the pid that you see when
> browsing a google plus album.
>
> When I execute this code, the result is
>
> 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 mypackage.AuthenticationTest.authenticate(AuthenticationTest.java:70)
>
>
> What am I doing wrong here?
>
>>
>>>>
--
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.