How to generate JWT token for a user without calling .login(email, password)?

default discord avatar
bombnp
7 months ago
4

I am using Google OAuth to authenticate my users. When I receive google id token, I would verify it and then find the user with the corresponding email. However, I don't know how to generate the JWT for that specific user via local API without specifying email and password (especially since there's no password)



Or is it not supported at the moment?

  • discord user avatar
    dribbens
    Payload Team
    7 months ago

    Hey, there is a lot that goes into making your auth strategy. It is tough to explain the details, but you'll need to sign your own JWT in a new custom endpoint route and use the

    disableLocalStrategy

    auth option as that will turn off the built-in email + password fields along with other auth features you won't want under your strategy.



    This was a really good write up on what you need in another community-help post that could help:

    https://discord.com/channels/967097582721572934/1073356002101035108/1073672246503166022
  • default discord avatar
    bombnp
    7 months ago

    oh my that really is extensive. I've implemented it like that as well. Thanks for reply!

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.