Closed hassaannoor closed 1 year ago
Hey @hassaannoor, thanks for the question, you could do that like this:
$user = get_user_by( 'ID' , $user_id );
$auth = new \JWTAuth\Auth;
$token = $auth->generate_token( $user );
Cheers,
@dominic-ks Can't thank you enough. You just saved me hours.
And right now I really wanna use emojis to express my dropped jaw at your response time. Salute.
Thank you so much.
Hello team,
I need this because I'm authing a user using google SSO and then creating a user with wp_insert_user. But when the user with the email already exists, I need a way to create a token for them. I can provide the username but not the password. So, I need a way to generate a token for the user given just their user id. This is happening in the backend so it's secure.
Thanks for your continuous development efforts.