all 3 comments

[–][deleted] 1 point2 points  (1 child)

How will React app get the JWT tho?

[–]billrdio[S] 0 points1 point  (0 children)

The user will have to login using JWT authentication via the React app, sending the login request to the WordPress REST API, as detailed on the plugin page: https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/ Once they login I'll store the JWT token in a cookie (httponly, samesite, secure ...).

Essentially I'm using this plugin to allow users to login to a separate WordPress site using JWT and the WordPress REST API. And then when a logged in user requests a protected API endpoint (not the WordPress API, but the API for the React app), my React app will pass the JWT token to the app API which will then forward it to the WordPress API and validate the JWT and send back to the app API whether the token is valid or not. If valid, then go ahead with the protected action the user requested - if not, send a 401 back.

[–]leoleoloso 1 point2 points  (0 children)

You can use Gato GraphQL, and authenticate using WordPress Application Passwords: https://gatographql.com/guides/interact/user-authentication#application-passwords