0

내 파일의 변경 사항을 볼 수있는 푸시 알림과 함께 드라이브 API를 사용하려고합니다.Google 푸시 알림 결과가 401 오류로 설정 됨 Unauthorized WebHook 콜백 채널

안내 양식 Google을 따르십시오.

내 단계 :

1 단계 :

google search console

2 단계를 수행 도메인을 소유하고 있는지 확인 등록 수행이 (내가 여러 시도했다 도메인 URL)

,783,

만들기 알림 채널

이 내가 Google 앱 엔진에 배포 가지고있는은 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}`); 
    }); 
} 

그리고 난 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" 
} 
} 

, 난 정확하게 Google 가이드를 따라야했다. 그리고 제가 일하고있는 3 일이 지났습니다. (나쁜 영어 죄송합니다)

답변

0

만약 내가 잘못 정정 해줘 -하지만하여 Goolge 드라이브 API를 사용하고 성공적으로 내 등록 된 응용 프로그램의 OAuth 토큰을 생성했다 요청을 할 수 있도록. 등록 했니? 응용 프로그램을 인증하는 방법을 여기에서 볼 수 없다면 google은 다른 방법으로 https://developers.google.com/drive/v3/web/about-auth을 제공합니다.

토큰을 얻은 후에는 요청에 헤더 속성으로 추가해야합니다.

'인증': '무기명'.

Google Oauth 토큰은 생성 후 1 시간 후에 만료되므로 재생성해야합니다.

+0

나는 자동으로 요청에 대한 OAuth 토큰을 제공하는 drive.file.watch (https://developers.google.com/drive/v3/reference/files/watch)의 라이브 데모를 사용합니다. –