I am trying to access the Picasa Web API with the java client using OAuth2 and I am getting a NPE when trying to use the refresh_token to get an access_token. I went to the OAuth 2.0 Playground and created an access_token and a refresh_token and everything works fine on the Playground and I can use the access_token in my java app with the access_token from the Playground but the refresh token from the playground does not seem to work. This is the simple code test:
ACCESS_TOKEN test - Works: Credential credential = new GoogleCredential.Builder() .setTransport(HTTP_TRANSPORT) .setJsonFactory(JSON_FACTORY) .setClientSecrets(CLIENT_ID, CLIENT_SECRET) .build(); credential.setAccessToken(ACCESS_TOKEN); // ACCESS_TOKEN from the Playground REFRESH_TOKEN test - Fails: Credential credential = new GoogleCredential.Builder() .setTransport(HTTP_TRANSPORT) .setJsonFactory(JSON_FACTORY) .setClientSecrets(CLIENT_ID, CLIENT_SECRET) .build(); credential.setRefreshToken(REFRESH_TOKEN); // REFRESH_TOKEN from the Playground credential.refreshToken(); // <- the exception occurs here with this stack trace: Exception in thread "main" java.lang.NullPointerException at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191) at com.google.api.client.util.Preconditions.checkNotNull(Preconditions.java:127) at com.google.api.client.json.jackson2.JacksonFactory.createJsonParser(JacksonFactory.java:92) at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:85) at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:81) at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:88) at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287) at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307) at com.google.api.client.auth.oauth2.Credential.executeRefreshToken(Credential.java:570) at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:362) at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:489) at PicasaV2.main(PicasaV2.java:49) The rest of the code in both cases is a simple test: PicasawebService myService = new PicasawebService(APP_NAME); myService.setOAuth2Credentials(credential); URL feedUrl = new URL("https://picasaweb.google.com/data/feed/api/user/USEREMAIL?kind=album"); UserFeed myUserFeed = myService.getFeed(feedUrl, UserFeed.class); for (AlbumEntry myAlbum : myUserFeed.getAlbumEntries()) { System.out.println(myAlbum.getTitle().getPlainText()); } -- 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 google-picasa-data-api+unsubscr...@googlegroups.com. To post to this group, send email to google-picasa-data-api@googlegroups.com. Visit this group at http://groups.google.com/group/google-picasa-data-api. For more options, visit https://groups.google.com/d/optout.