Невозможно проверить настроенный URL с помощью ngrok. Сообщение об ошибке выглядит следующим образом:
Error
The URL couldn't be validated. Please try again.
Как только я пытаюсь подтвердить в настройках приложения, я получаю ошибку 403 в терминале
127.0.0.1 - - [30/Sep/2019 20:26:39] "GET /webhook?hub.mode=subscribe&hub.challenge=607343413&hub.verify_token=hello HTTP/1.1" 403 -
Мой код
import os, sys
from flask import Flask,request
app = Flask(__name__)
VERIFY_TOKEN = "hello"
@app.route('/', methods=['GET'])
def index():
return "This is a Facebook Messenger test bot server."
@app.route('/webhook', methods=['GET'])
def verify():
# webhook verification
if request.args.get('hub.mode') == 'subscribe' and request.args.get('hub.challenge'):
if request.args.get('hub.verify_token') == VERIFY_TOKEN:
return 'Verification token missmatch', 403
return request.args['hub.challange'], 200
return 'verification token', 200
if __name__ == '__main__':
app.run(debug = False)
ОБНОВЛЕНИЕ:
Я изменил if request.args.get ('hub.verify_token') == VERIFY_TOKEN: to if request.args.get ('hub.verify_token')! = VERIFY_TOKEN:
Вот что происходит сейчас, когда я пытаюсь включить интеграцию с веб-крючками.
127.0.0.1 - - [30/Sep/2019 20:45:49] "GET /webhook?hub.mode=subscribe&hub.challenge=2128593822&hub.verify_token=hello HTTP/1.1" 500 -
Traceback (most recent call last):
File "/users/ec4/user/super-duper-telegram/env/lib/python3.6/site-packages/flask/app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "/users/ec4/user/super-duper-telegram/env/lib/python3.6/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/users/ec4/user/super-duper-telegram/env/lib/python3.6/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/users/ec4/user/super-duper-telegram/env/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/users/ec4/user/super-duper-telegram/env/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/users/ec4/user/super-duper-telegram/env/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/users/ec4/user/super-duper-telegram/env/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/users/ec4/user/super-duper-telegram/env/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/users/ec4/user/super-duper-telegram/env/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/users/ec4/user/super-duper-telegram/env/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/users/ec4/user/super-duper-telegram/app.py", line 18, in verify
return request.args['hub.challange'], 200
File "/users/ec4/user/super-duper-telegram/env/lib/python3.6/site-packages/werkzeug/datastructures.py", line 443, in __getitem__
raise exceptions.BadRequestKeyError(key)
werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
KeyError: 'hub.challange'
127.0.0.1 - - [30/Sep/2019 20:45:57] "GET /webhook HTTP/1.1" 200 -