rest api - How to set JWT token with PHP on successful login?

I'm creating a decoupled application: the frontend is built with React, the backend uses Wordpress. However, due to

I'm creating a decoupled application: the frontend is built with React, the backend uses Wordpress. However, due to some limitations the login and registration frontend pages must use a Wordpress theme, so the user is redirected to the React app only after login.

In the React frontend, I need to assign the current user a JWT token so that they can make authenticated requests; so I have to set a JWT token when they log in from the Wordpress theme. Basically, I need to set the JWT token when I'm still in a PHP application.

I've read that you can do API requests in PHP with curl (which I've never used before), so my best bet right now is to hook into the wp_login action, and use the JWT Authentication plugin for Wordpress to make a request with curl to the endpoint that generates a token.

This solution feels a bit weird to me though. Can you think of a better one?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745663932a4639008.html

相关推荐

  • rest api - How to set JWT token with PHP on successful login?

    I'm creating a decoupled application: the frontend is built with React, the backend uses Wordpress. However, due to

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信