-
Notifications
You must be signed in to change notification settings - Fork 2
Curl Example
Scott Robertson edited this page Jan 21, 2021
·
1 revision
Here is a basic example of how Tokenable works, with Curl. First, make a request to login
curl --location --request POST 'http://localhost:3000/login' \
--form 'email="email@example.com"' \
--form 'password="password123"'
This will then return your token, and user_id.
{
"data":{
"token":"eyJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7InVzZXJfaWQiOjEsInZlcmlmaWVyIjoiM2ExZGNlODItN2YwNC00Mjk1LTljN2QtYzUzYmQ4OGVjNTI3In0sImV4cCI6MTYxMTgzNTA5NH0.UShx3dxVNqGVVih9XoVFboc4p7jzqI2LQAz1-8xUG0I",
"user_id":1
}
}
You should then use that token in all future requests to your API:
curl --location --request GET 'http://localhost:3000/user' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7InVzZXJfaWQiOjEsInZlcmlmaWVyIjoiM2ExZGNlODItN2YwNC00Mjk1LTljN2QtYzUzYmQ4OGVjNTI3In0sImV4cCI6MTYxMTgzNTA5NH0.UShx3dxVNqGVVih9XoVFboc4p7jzqI2LQAz1-8xUG0I'