I tried a bunch of tutorials, here is an example of one of them
https://nickmccullum.com/build-facebook-bot-python-flask/
Request is send:
127.0.0.1 - - [02/May/2022 10:18:15] "GET /?hub.mode=subscribe&hub.challenge=646416116&hub.verify_token=YOUR_VERIFY_TOKEN HTTP/1.1" 200 -
But when trying to validate, the Webhook throws this error:
Validation of the callback URL or confirmation token failed. Confirm the information provided or try again later.
what could be the problem
Related
I am using python fastApi as a framework, I have the following post method:
async def post(request:Request):
logger.info(f"recieve a sns notification {request}")
return {"message": f"got message {await request.body()} "}
I am aware that in the above method there is no logic to confirm it is just a showcase for my real issue
I subscribed the endpoint through the console, and the status is Pending confirmation
every time press the "Request Confirmation" button I can see in cloudWatch logger:
"POST /api/customer-profiles HTTP/1.1" 307 Temporary Redirect
when I use the following code from my local machine:
import requests
import boto3
import json
url = "https://<my-domain>/api/customer-profiles"
payload = {"a": {"a":"v"}}
res = requests.post(url=url, data=json.dumps(payload))
the response:
<Response [200]>
with content
b'{"message":"got message b\'{\\"a\\": {\\"a\\": \\"v\\"}}\' "}'
in cloud watch is can also see:
INFO: <ip> - "POST /api/customer-profiles HTTP/1.1" 307 Temporary Redirect
#logger wirtes!!
recieve a sns notification <starlette.requests.Request object at 0x7ff459d50610>
INFO: <ip> - "POST /api/customer-profiles/ HTTP/1.1" 200 OK
I Am not sure what i am doing wrong
The endpoints is working (also all test are good) but only for the SNS confirmation its NOT,
what am I doing wrong? why the endpoint never get the request?
its all come to a "/"
see the following answer
fastapi make the redirect between www.example.com/api to www.exmaple.com/api/ there is a location redirect between the tow.
once I wrote the subscriber HTTP in the SNS with a \ all was solved.
I am trying to create a client and upload an image in Form React Component, when I send it to the backend using Axios I get the message "POST http://127.0.0.1:8000/ 400 (Bad Request)". If I create a client using postman, It creates it but when I do it in my React App, I get the 400 message. Does someone know what to do?
I'm trying to add twitter sign in option to my python application and I'm getting following error from web server:
GET /social-auth/login/twitter/ HTTP/1.1" 500 103190 403 Client Error: Forbidden for url: https://api.twitter.com/oauth/request_token
I work on dev environment django + unicorn with SSL on localhost. I've checked following instruction on Twitter callback url's guide:
Don’t use localhost as a callback URL Instead of using localhost, please use a custom host locally or http(s)://127.0.0.1.
My callback URL: https://127.0.0.1:8000/social-auth/complete/twitter/
Is it possible to make it work without hosting real domain?
Yes, you can test your API on the development server.
Try this one:
https://localhost:8000/complete/twitter/
or
https://127.0.0.1:8000/complete/twitter/
Update your callback URL in your App's Setting.
Refer to this article for more understanding :
https://github.com/python-social-auth/social-app-django/issues/164
I've been getting some weird http requests on my AWS server. I run a python3/flask v0.12 web server on it.
Does anyone know if I should be worried about the requests below?
Is there anyway to automatically reject old http requests (e.g. http/0.8 or http/0.9) using flask?
77.72.83.21 - - [18/Mar/2018 22:46:32] "╚ *%à Cookie: mstshash=Test" HTTPStatus.BAD_REQUEST -
77.72.83.21 - - [18/Mar/2018 22:46:34] code 400, message Bad HTTP/0.9 request type ('\x03\x00\x00*%à\x00\x00\x00\x00\x00Cookie:')
77.72.83.21 - - [18/Mar/2018 22:46:34] "╚ *%à Cookie: mstshash=Test" HTTPStatus.BAD_REQUEST -
213.202.230.144 - - [19/Mar/2018 11:11:00] code 400, message Bad HTTP/0.9 request type ('\x03\x00\x00/*à\x00\x00\x00\x00\x00Cookie:')
213.202.230.144 - - [19/Mar/2018 11:11:00] "╚ /*à Cookie: mstshash=Administr" HTTPStatus.BAD_REQUEST -
I use python and google-api-python-client==1.6.2 to work with user Google Drive's. Everything works perfectly without any bugs, but I didn't receive any push notification from Google Drive (Google Drive API Documentation). "Registering your domain" successfully completed. "Creating notification channels" completed with Channel object returning to me.
My code:
try:
drive_service.files().watch(
fileId='CPw3cbyqkoC1QMK48R24-Z2CG9w',
body=dict(
id=str(uuid.uuid4()),
resourceId='CPw3cbyqkoC1QMK48R24-Z2CG9w',
type='web_hook',
address='https://my-domain-address/web_hook'
)
).execute()
except HttpError as err:
logger.exception('HttpError {}: content={}'.format(err.uri, err.content))
Response:
{
u'resourceId': u'CPw3cbyqkoC1QMK48R24-Z2CG9w',
u'kind': u'api#channel',
u'expiration': u'1495448262000',
u'id': u'8837a4ad-98c0-4e89-8899-c07e12e3bffc',
u'resourceUri': u'https://www.googleapis.com/drive/v3/files/0B2lHB_g_GJY9RWx6UkRjWUFjSVU?acknowledgeAbuse=false&alt=json&supportsTeamDrives=false&alt=json'
}
After it there are not any requests to https://my-domain-address/web_hook when User modify watched Google Drive resource.
Have you any ideas what I do wrong?
Log messages linked with the problem that I found while search a solution:
64.233.172.141 - - [22/May/2017:09:11:10 +0000] "POST /web_hook HTTP/1.1" 403 807 "-" "APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)"
64.233.172.143 - - [22/May/2017:09:11:12 +0000] "POST /web_hook HTTP/1.1" 403 807 "-" "APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)"
64.233.172.143 - - [22/May/2017:09:11:13 +0000] "POST /web_hook HTTP/1.1" 403 807 "-" "APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)"
So I'm receiving the Google Drive requests to my webhook.
Firstly I think that Nginx is blocking them, but after I had seen that all requests are POST.
So I came to the problem of forwarding POST requests. Also I use Django and forgot disable CSRF protection to webhook. This is a solution of my problem.
I'll be glad if it helps someone.