Node.js 谷歌+;使用nodejs客户端插入瞬间

Node.js 谷歌+;使用nodejs客户端插入瞬间,node.js,oauth-2.0,google-plus,google-api-nodejs-client,Node.js,Oauth 2.0,Google Plus,Google Api Nodejs Client,有没有人能够让GoogleAPInodejs客户端成功地插入一个瞬间 无论我尝试什么,我都会得到一个普通的400“无效值”错误,但无法缩小无效值的范围,因为该错误也不起作用 是否因为缺少数据请求VisibleActions参数?我正在使用passport.js的require('passport-google-oauth').OAuth2Strategy来处理oauth访问,这部分工作正常,但我不知道如何将requestvisibleactions合并到oauth请求流中,因为这肯定不是来自客户

有没有人能够让GoogleAPInodejs客户端成功地插入一个瞬间

无论我尝试什么,我都会得到一个普通的400“无效值”错误,但无法缩小无效值的范围,因为该错误也不起作用

是否因为缺少数据请求VisibleActions参数?我正在使用passport.js的
require('passport-google-oauth').OAuth2Strategy
来处理oauth访问,这部分工作正常,但我不知道如何将requestvisibleactions合并到oauth请求流中,因为这肯定不是来自客户端表单

下面是我尝试做的一个片段(使用最新版本的
googleapis
,v1.0.2):

(过时的w.r.t.
googleapis的旧版本


(客户端,其中数据requestvisibleactions的使用更为明显)

正如您所推测的,您需要
request\u visible\u actions
参数作为调用oauth端点的URL的一部分

看起来passport google oauth的当前版本不支持此参数。从几个未解决的问题和pull请求来看,不清楚作者是否会响应添加它的请求。您有两种可能的选择:

  • 切换到使用google api nodejs客户端中包含的OAuth支持

  • 修补passport google oauth代码。(并可能提交一个pull请求,希望它对其他人有用。)

  • 我不使用passport.js或有问题的passport模块,因此我无法测试这一点,但基于github存储库,我认为您可以在第136行之后和return语句之前插入以下内容:

    if (options.requestVisibleActions) {
      // Space separated list of allowed app actions
      // as documented at:
      //  https://developers.google.com/+/web/app-activities/#writing_an_app_activity_using_the_google_apis_client_libraries
      //  https://developers.google.com/+/api/moment-types/
      params['request_visible_actions'] = options.requestVisibleActions;
    }
    

    谢谢你,囚犯,这绝对是一个巨大的崩溃。我已经实现了您建议的修补程序,但现在收到401“无效凭据”错误(以前是400“无效值”错误)。我肯定认为这是一条正确的道路,如果我发现哪里出了问题,我会做出回应。再次感谢你的帮助!根据您第一次身份验证的时间,您的令牌可能已过期,并且看起来您没有使用刷新令牌。@fisch2,这对您有用吗?如果是,您可以共享路由处理程序吗?我的类似于app.get('/auth/google',redirect,
    passport.authenticate('google',{scope:['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/plus.moments.write'],accessType:'offline'})但它不起作用。@Sparky-您可能想提出一个新问题,给出您的请求的详细信息以及“它不起作用”的含义。但听起来你没有像我们讨论的那样指定“request\u visible\u actions”参数。@囚犯,谢谢,实际上我在这里提出了一个新问题
    
    if (options.requestVisibleActions) {
      // Space separated list of allowed app actions
      // as documented at:
      //  https://developers.google.com/+/web/app-activities/#writing_an_app_activity_using_the_google_apis_client_libraries
      //  https://developers.google.com/+/api/moment-types/
      params['request_visible_actions'] = options.requestVisibleActions;
    }