{ "user_id": "123", "first_name": "John", "last_name": "Smith", "display_name": "john", "role": "Customer", "avatar_urls": {}, "email": "users@emailaddress.xyz", "extras": { "jwt_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOlwvXC9jb2NhcnRhcGkubG9jYWwiLCJpYXQiOjE3Mzk3NTEzNzIsIm5iZiI6MTczOTc1MTM3MiwiZXhwIjoxNzQwNjE1MzcyLCJkYXRhIjp7InVzZXIiOnsiaWQiOjEsInVzZXJuYW1lIjoic2ViYXN0aWVuIiwiaXAiOiIxMjcuMC4wLjEiLCJkZXZpY2UiOiJIVFRQX1hfVUNCUk9XU0VSX0RFVklDRV9VQSJ9LCJzZWNyZXRfa2V5IjoiYmFuYW5hIn19.aBuyRwAtvGb6SI4BB_MN4NYN01jqVZN4PPnd1jfW2UA", "jwt_refresh": "90efc95f1d85e465951d10c309897629524b7fc1b40dfab75ed68f7c8540468a05b8b26995685821f52cf736edb566f3317432288af4c6e4edc281f6ab7af371" }, "dev_note": "Don't forget to store the users login information in order to authenticate all other routes with CoCart."}
If you require to pass the user-agent header when making requests. Applying it when logging in must be done for the token to remain valid. If you decide to pass the user-agent header after, then the token will no longer be valid and you will have to request a new one.
2. Use the TokenMake authenticated requests using the token. Here’s an example using Cart endpoint to get the current user’s cart:
Copy
curl -X GET \ https://your-site.com/wp-json/cocart/v2/cart \ -H "Authorization: Bearer YOUR-JWT-TOKEN"
3. Refresh TokenWhen the access token expires, use the refresh token to get a new one: