【问题标题】:oAuth2 code for replacement for of oAuth1 in Google DocsoAuth2 代码,用于替换 Google Docs 中的 oAuth1
【发布时间】:2015-04-06 02:31:14
【问题描述】:

以下是函数调用和函数,它有助于 oAuth1 在 Google Apps Script for Authorization 中来自 google Docs,但由于 oAuth1 从 15 年 4 月 20 日起停止使用,因此很难找到 oAuth2 的替换代码。 请帮助我。

var auth = googleOAuth_('docs',scope);

function googleOAuth_(name,scope)
{
var oAuthConfig = UrlFetchApp.addOAuthService(name);
oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oAuthConfig.setConsumerKey("anonymous");
oAuthConfig.setConsumerSecret("anonymous");
return {oAuthServiceName:name, oAuthUseToken:"always"};
}

【问题讨论】:

标签: javascript google-apps-script google-docs-api google-oauth oauth-1.0a


【解决方案1】:

我建议您查看云端硬盘高级服务。它具有 REST api 接口的所有精细功能,但与 Apps 脚本服务紧密集成。

https://developers.google.com/apps-script/advanced/drive

在两种情况下,您可能需要自己处理对 Drive sdk 的访问:使用服务帐户令牌或访问 appfolder 时。在任何一种情况下,您都可以使用如下库: https://github.com/googlesamples/apps-script-oauth2

那个库的自述文件已经很完整了。

【讨论】:

    猜你喜欢
    • 2015-07-28
    • 1970-01-01
    • 2014-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多