simple-jwt-login icon indicating copy to clipboard operation
simple-jwt-login copied to clipboard

Cannot authenticate protected APIs with JWT

Open giricgoyal opened this issue 2 years ago • 1 comments

Bug Description

Not able to authenticate protected apis with jwt token. Receiving invald_username error. Using postman to create and test the workflow.

Configuration: General: general

Login: login

Authentication: Authentication

Steps to reproduce:

  1. Hit the Authentication api with paramters:
{
    "email": "[email protected]",
    "password": "password",
    "AUTH_KEY": "{{PASSPORT_API_KEY}}"
}
  1. Hit the posts api /wp-json/wp/v2/posts with Authorization Header and JWT token received from step 1
Authorization: "Bearer <JWT TOKEN>"

Received the error:

{
    "code": "invalid_username",
    "message": "<strong>Error</strong>: Unknown username. Check again or try your email address.",
    "data": null
}

Environment

Question Answer
WordPress version 6.0.1
Simple-JWT-Login plugin version 3.4.6

giricgoyal avatar Aug 18 '22 05:08 giricgoyal

Same here It seems like the JWT auth is triggering the "Default authentication filters" The file wp-includes/user.php function "wp_authenticate_username_password" which throws this error

maxmadknight avatar May 29 '24 09:05 maxmadknight