Oauth 2.0 获得;无效凭证“;从Google小工具执行融合表插入时

Oauth 2.0 获得;无效凭证“;从Google小工具执行融合表插入时,oauth-2.0,google-apps,google-fusion-tables,Oauth 2.0,Google Apps,Google Fusion Tables,我们有一个Google小工具,它通过Fusion Table API和用户的Google帐户连接到Fusion表。它执行选择和插入 我们使用OAuth1(opensocial的shindig库)构建了这个小工具。对于不推荐使用的Fusion Table API版本,它工作得很好。当我们将其迁移到新的PAPI时,select QQ工作正常,因为不需要使用OAuth2进行身份验证。但是,对于插入件,这是必要的。opensocial的文档尚未完全更新:http://docs.opensocial.or

我们有一个Google小工具,它通过Fusion Table API和用户的Google帐户连接到Fusion表。它执行选择和插入

我们使用OAuth1(opensocial的shindig库)构建了这个小工具。对于不推荐使用的Fusion Table API版本,它工作得很好。当我们将其迁移到新的PAPI时,select QQ工作正常,因为不需要使用OAuth2进行身份验证。但是,对于插入件,这是必要的。opensocial的文档尚未完全更新:http://docs.opensocial.org/display/OSREF/OpenSocial+规范+注意事项

我不知道如何成功地使用OAuth2执行插入。我们拥有在域级别读/写的API权限,用户拥有对Fusion表的所有者权限

我得到的错误是说“无效凭证”相当模糊,我不知道为什么

这是我们的小工具标题:

<OAuth>
    <Service name="google">
    <Access url="https://www.google.com/accounts/OAuthGetAccessToken" method="GET" />
    <Request url="https://www.google.com/accounts/OAuthGetRequestToken?scope=https://www.googleapis.com/auth/fusiontables%20https://docs.google.com/feeds/default/private"
         method="GET" />
    <Authorization url="https://www.google.com/accounts/OAuthAuthorizeToken?oauth_callback=http://oauth.gmodules.com/gadgets/oauthcallback" />
    </Service>
</OAuth>

谢谢

如果您正在执行写入请求,则需要提供oauth令牌,该令牌对用户访问表的权限进行编码。看起来这可能在gadgets.io.RequestParameters.OAUTH_REQUEST_令牌中。该键用于从公共表进行读取访问。此外,您可能需要将OAUTH_服务名称设置为“fusiontables”。

Warren,谢谢。您是否有提供此示例的示例代码?
<OAuth2>
    <Service name="google">
    <Authorization url="https://www.google.com/accounts/OAuthAuthorizeToken?oauth_callback=http://oauth.gmodules.com/gadgets/oauth2callback" />
    </Service>
</OAuth2>
options = {};
options[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT;
options[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
options[gadgets.io.RequestParameters.POST_DATA] = postData;
options[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.OAUTH2;
options[gadgets.io.RequestParameters.HEADERS] = {'Authorization':'{encrypted fusiontable key}'};  //not sure if this helps but its extra
options[gadgets.io.RequestParameters.OAUTH_SERVICE_NAME] = "google";
options[gadgets.io.RequestParameters.OAUTH_USE_TOKEN] = "always";

URL = https://www.googleapis.com/fusiontables/v1/query?key={encrypted fusiontable key} &client_id={id number}”;
postData=”sql=INSERT…”;
gadgets.io.makeRequest(URL, handlerWrapper, options);