【问题标题】:setting google push notifications result to error 401 Unauthorized WebHook callback channel将谷歌推送通知结果设置为错误 401 未经授权的 WebHook 回调通道
【发布时间】:2018-03-06 05:01:21
【问题描述】:

我正在尝试将驱动器 API 与推送通知一起使用,让我监视文件的更改。

我遵循谷歌的指南。

我的步骤:

第 1 步:验证您是否拥有该域 完成

google search console

第 2 步:注册您的域 完成(我尝试了多个 URL)

google domain verification

创建通知渠道

这是我在谷歌应用引擎上部署的 webhook 的简单节点服务器。

/* jshint node: true */
'use strict';

const key = require('./SBSWideDomainDev.json');
const google = require('googleapis');
const express = require('express');
var path = require("path");
const logging = require('./logging');

const app = express();

app.enable('trust proxy');

app.post('/notification', (req, res, next) => {
    logging.info(res.body);
    res.status(200).json(res.body);
});

if (module === require.main) {
    var test = 8080;
    const server = app.listen(test, () => {
        const port = server.address().port;
        console.log(`App listening on port ${port}`);
    });
}

我在 google 页面上为 file.watch 使用现场演示

fileId : "some FileId",
request body:
{
  "type": "web_hook",
  "address": "https://notif-dot-sullivan-business-solution-dev.appspot.com/notification",
  "id": "e64d0c44-f9a2-4db8-8d21-94ee0904dcb7"
}

回复:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "push.webhookUrlUnauthorized",
    "message": "Unauthorized WebHook callback channel: https://notif-dot-sullivan-business-solution-dev.appspot.com/notification"
   }
  ],
  "code": 401,
  "message": "Unauthorized WebHook callback channel: https://notif-dot-sullivan-business-solution-dev.appspot.com/notification"
 }
}

我完全不知道问题出在哪里,我完全按照谷歌指南进行操作。我已经花了三天时间来处理它。

(抱歉英语不好)

【问题讨论】:

    标签: node.js google-app-engine push-notification google-api drive


    【解决方案1】:

    如果我错了,请纠正我 - 但我使用了 Goolge Drive API 并且为了能够成功发出请求,我必须为我注册的应用程序生成 OAuth 令牌。你注册了吗?如果这里没有看到如何验证您的应用程序,谷歌提供了不同的方法来做到这一点https://developers.google.com/drive/v3/web/about-auth。

    获得令牌后,您应该将其作为标头属性添加到您的请求中。

    “授权”:“承载”。

    另外请记住,Google Oauth 令牌会在生成后 1 小时内过期,您应该重新生成它。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-13
    • 2014-07-18
    • 2021-04-15
    • 2017-06-06
    • 2017-07-20
    • 1970-01-01
    • 1970-01-01
    • 2014-11-02
    相关资源
    最近更新 更多