5

I don't understand why I can't save AppIdentityCredential with AppEngineDataStoreFactory

AppEngineDataStoreFactory newFactory = new AppEngineDataStoreFactory();
AppIdentityCredential credential = new AppIdentityCredential.Builder(SCOPES).build()

//line with error
if (newFactory.getDataStore(StoredCredential.DEFAULT_DATA_STORE_ID)
                              .set(userId, new StoredCredential(credential))) {
  return  credential;
}
return null;

AppIdentityCredential is not serializable and StoredCredential accept only Credential object... What's the logic????

Cédric

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449

1 Answers1

0

StoredCredential(Credential) method takes a Credential object [1], not a AppIdentityCredential object [2].

You are using the wrong object for that method.

[1] - https://code.google.com/p/google-oauth-java-client/source/browse/google-oauth-client/src/main/java/com/google/api/client/auth/oauth2/StoredCredential.java?r=e193e3ede28cd312eef14adb9566a7f0476425e7

[2] - http://javadoc.google-api-java-client.googlecode.com/hg/1.8.0-beta/com/google/api/client/googleapis/extensions/appengine/auth/oauth2/AppIdentityCredential.html

Ying Li
  • 2,500
  • 2
  • 13
  • 37
  • Thanks, and? I don't understand the difference between Credential object and AppIdentityCredential object... Someone can explain? :) – Cédric Lallier Dec 30 '14 at 22:04
  • They are Apples and Oranges; they are completely different classes/objects. They all use the word Credential, so maybe it looked like they can be used interchangeably, but that's not the case. You need to use the Credential object from OAuth... See this link for details - https://developers.google.com/api-client-library/python/guide/aaa_oauth#credentials – Ying Li Jan 05 '15 at 22:20