Fusion Table and Google Service Accounts

a 夏天 提交于 2019-12-03 13:31:31

问题


I am trying to use Google Service Accounts to access Fusion table from my AppENgine Java App. This code snippet is used to obtain OAuth access token:

 ArrayList<String> scopes = new ArrayList<String>();
 scopes.add("https://www.googleapis.com/auth/fusiontables");
 DataAccessService fusionTablesService = EnvironmentServic.getEnvironmentService().getService(DataAccessService.class);
 String token = AppIdentityServiceFactory.getAppIdentityService().getAccessToken(scopes).getAccessToken();

I was able to successfully obtain access token, but when I am trying to execute CREATE TABLE query i got:

   <HTML>
    <HEAD>
     <TITLE>Login required</TITLE>
    </HEAD>
    <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
     <H1>Login required</H1>
     <H2>Error 401</H2>
    </BODY>
   </HTML>

Do service account works with Fusion Tables?


回答1:


I'm not terribly familiar with Fusion Tables, but it is likely that you need to either:

1) Grant permission to the service account (the "email address" is found in the admin console) to access the table. This would probably happen through The sample at https://developers.google.com/appengine/articles/prediction_service_accounts may be helpful as a starting point for this process.

2) Log in a user who has access to the table (or whose data you're trying to access) and have them authorize access for the application using the three-legged OAuth flow. If you're accessing data that is owned by an end user (ex: joe@gmail.com), then you'll probably need to do this.

Hope this helps.



来源:https://stackoverflow.com/questions/10338497/fusion-table-and-google-service-accounts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!