5
I’m using the library Requests
Python to make HTTP requests.
I was able to post a request quietly in order to obtain 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")