0

I am trying to use the drive API to test watching one of my google drive's documents...

I have created a localhost server using python flask...

This is my code for it

from flask import Flask, render_template, request, url_for
app = Flask(__name__)

@app.route('/')
def display():
    user = {'nickname': 'Miguel'}  # fake user
        return '''
        <html>
            <head>
                    <title>Home Page</title>
                <meta name="google-site-verification" content="XXXX" />
            </head>
            <body>
                    <h1>Hello, ''' + user['nickname'] + '''</h1>
            </body>
        </html>
     '''
if __name__=='__main__':
    app.run()

@app.route('/hello', METHODS=['POST'])
def hello():
    return request.get_data()

I use ngrok to connect my localhost to the internet...

This doesn't even matter however because the drive API cannot connect to the server

as when I use the Google Drive API in the API explorer it gives me

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "push.webhookUrlUnauthorized",
    "message": "Unauthorized WebHook callback channel: https://44c689c2.ngrok.io"
   }
  ],
  "code": 401,
  "message": "Unauthorized WebHook callback channel: https://44c689c2.ngrok.io"
 }
}

The items that I put into the body are:

{
"address":"https://44c689c2.ngrok.io",
"type":"web_hook",
"id":"abc123"
}

Is there any way to fix this?? Thanks...

1 Answers1

0

You have the same issue in this post.

To use Push Notifications in Google Calendar make sure you followed the instructions here:

  1. Register the domain of your receiving URL in Google Dev Console. Go to Credentials and click Domain Verification for the webhook setup.

enter image description here

For example, if you plan to use https://yourdomainexample.com/notifications as your receiving URL, you need to register https://yourdomainexample.com. Set up your receiving URL, or "Webhook" callback receiver.

  1. This is an HTTPS server that handles the API notification messages that are triggered when a resource changes.

  2. Set up a notification channel for each resource endpoint you want to watch.

A channel specifies routing information for notification messages. As part of the channel setup, you identify the specific URL where you want to receive notifications. Whenever a channel's resource changes, the Google Calendar API sends a notification message as a POST request to that URL.

You may also check this this SO thread.

MαπμQμαπkγVπ.0
  • 5,887
  • 1
  • 27
  • 65