generate_jwt
This endpoint is used to generate JSON Web Token for the user for JSON API Plugin for WordPress. This token is used for user authentication throughout the user related endpoints.
Generated JWT – token is valid for 14 days.
Optional ‘seconds’ var can be used to limit this. If provided, generated token will be valid for that many seconds, otherwise default is for 14 days.
Example for valid jwt for 1 minute:
http://localhost/api/userplus/generate_jwt/?username=john&password=PASSWORD-HERE&seconds=60
You can can also submit the data using JSON format. Please see following examples of sending requests using Postman
Post method values screenshot:
Post method raw JSON values screenshot:
Resource URL
http://localhost/api/userplus/generate_jwt/
Method
POST
Required Parameters
- username
- password
- key – get API key from Settings > User Plus
Optional Parameters
- seconds - 60 means 1 minute - default is for 14 days
Endpoint Returns
valid JWT token
Sample Request URL
http://localhost/api/userplus/generate_jwt/?username=john&password=PASSWORD-HERE
Sample Response
{
"status": "ok",
"jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1OTQ1NzMwOTEsImlzcyI6Ind3dy53cHBpbS5jb20iLCJuYmYiOjE1OTQ1NzMxNTEsImV4cCI6MTU5NTc4Mjc1MSwidXNlciI6eyJpZCI6MSwidXNlcm5hbWUiOiJwaW0tYWRtaW4iLCJjb29raWUiOiJwaW0tYWRtaW58MTU5NTc4Mjc1MXxia0pyUHBTa3hyYTdrRWJydFViTGhvcHFyUUFFSm1tVkhRTmYyOXRzdE1NjhjYTE1YjVjOTdiZDVmZDcxZTg0YmEwODdlMzI0NDYyMjU0OTZhNWVhM2FlNmMxMmEwYjI2ZjkifX0.1MAEub7t1BHYiPTLJGbAr8HmL0bXklJp_yuEnrm5"
}