1
I created a login screen and when I click login I get back a JWT token and its expiration. What I want to do is store this token and redirect it to another page. I know I have to do the authorization using header but I don’t know exactly how to do it. I’m using Jquery
<form action="https://www.teste.teste.com:3000/api/v1/sign-in " method="post" name="login" id="login">
<div class="box">
<div class="box-top">
<p style="position:absolute; top:30px; left:160px; color:white; font-size: 150%;">Logar</p>
</div>
</div>
<input type="text" id="name" class="input_text" name="name" placeholder="Usuário" value="pontual">
<div class="container">
<input type="password" id="password" name="password" class="input_text" placeholder="Senha" value="#P0ntu@l">
<input type="hidden" class="input_text" name="type_login" id="type_login" value="service"/>
<div>
</div>
</div>
<button type="submit" id="salvar" name="myButton" value="foo">Logar</button>
</div>
</form>
That’s the return I get:
{
id: 1,
name: "pontual",
token: "JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NTU1OTM4OTksImlkIjoxLCJuYW1lIjoicG9udHVhbCIsInR5cGVfbG9naW4iOiJzZXJ2aWNlIn0.WJuGoxa0ditgNhylkKkXBacvqUAA7GXDIeJCW5v1rOU",
token_expires: "2019-04-18 10:24:59"
}
Thanks for the answer! If I understand correctly (I’m still a beginner) where is the url I put the http I use in the form? And date I put specifically what? the login and password used?
– Gabriel Midão
Exactly Gabriel, in the URL are the data to where the request goes, and on the date will be the other data, see how your api wants to receive this data and assemble as requested by it.
– Daniel Obara