nicumicle / simple-jwt-login

This plugin allows you to log in, register, authenticate, delete and change the user password to a WordPress website using a JWT.
http://wordpress.org/plugins/simple-jwt-login/
GNU General Public License v3.0
83 stars 23 forks source link

bug: Unable to get user profile data from API #106

Closed DudeThatsErin closed 6 months ago

DudeThatsErin commented 6 months ago

Bug Report

Plugin Version

3.53.3

PHP Version

8.1.27

WordPress Version

6.5.2

Bug description

I am trying to retrieve information from the wordpress database using the plugin like the user's name (first and last) and email to store in my secure storage for my app.

When I attempt to use the validate JWT URL address I get this error:

{"success":false,"data":{"message":"Unable to find user user property in JWT.( Settings: user.id )","errorCode":29}}

Because the data that is retrieved is this:

{"success":true,"data":{"jwt":"JWTTOKENHIDDEN"}}

I have the payload set up for everything correctly as far as I'm aware.

Screenshot 2024-05-01 at 11 26 27 AM

Other installed plugins (optional)

This is our development site and we make heavy use of plugins so we have a lot:

nicumicle commented 6 months ago

Hi @DudeThatsErin ,

The issue here is that you have set the wrong payload key for the JWT.

Please go to Simple JWT Plugin settings -> Login -> JWT parameter key and set it to "id" or "email" ( without the double quotes). image

As I see in the error message, currently you set "user.id", but if you generate the JWT in the "/simple-jwt-login/v1/auth" endpoint, the payload will contain the following keys: id, email, username, site...

You can check your JWT payload on https://jwt.io/.

DudeThatsErin commented 6 months ago

Then why use user.id as an example if user.id doesn't work?

nicumicle commented 6 months ago

Now that you mentioned, i also see it very confusing. Most of the people generate JWT in the /auth endpoint. So definitely should be 'id' or 'email' .

nicumicle commented 6 months ago

I will close this issue.

The UI has been improved. image