I'm trying to get my app to upload to Fusion Tables without the need to grant every user write permissions to the table beforehand. This is because of security reasons and just to make the system simpler.
Currently, to create an instance of com.google.api.services.fusiontables.Fusiontables
, I do:
private static Fusiontables constructFusionTables(Context context) {
GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(context,
Arrays.asList("https://www.googleapis.com/auth/fusiontables"));
String username = "someuser@gmail.com";
credential.setSelectedAccountName(username);
return fusiontables = new Fusiontables.Builder(HTTP_TRANSPORT,
JSON_FACTORY, credential).setApplicationName("someappname")
.build();
}
When I try to use a service account email ( XXXXXXX@developer.gserviceaccount.com
), all the Fusion Tables queries made with that FusionTables
instance fail telling me that name must not be null.
As a quick workaround for testing, I tried to hardcode a username ( someuser@gmail.com
) that is not on the device's Google Account list, but it gives me the same error.
The error doesn't appear when I use normal user@gmail.com
accounts that exist on the phone.
Could you guide me on how to implement a Service Account to Fusion Tables in Android?