I have written a Flask application. In that, I am using basic auth to restrict certain POST API views. From Python requests, I can access those views as -
print post(url, json=data, auth=('username', 'password'))
And from curl,
curl -a username:password -d "data" url
How to do the same in app.post ? I tried auth
, authorization
etc as parameters to post
but they were invalid.
response = self.app.post(
url,
data=data,
headers={
'content-type': 'application/json'
},
follow_redirects=True
)