I am using the Requests
Python library to make HTTP requests.
I was able to make a post request quietly in order to get a JWT token. But now I need to send this token through a header, but I have no idea how to do it.
The code I currently have is:
import requests
class Webservice(object):
def __init__(self):
self.authData = None
def authenticate(self, username, password):
credentials = {
"username" : username,
"password" : password
}
response = requests.post("http://exemplo/usuario/ajax-jwt-auth", data=credentials)
data = response.json()
if data.token:
#guarda o token
self.authData = data
return response
def getData(self):
#preciso passar o token por um header nessa requisição
return requests.get("http://exemplo/api/servicos")