Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hanzanati's avatar

Using an API key alongside JWT authentication

Using JWT in our API that services a mobile app, where users login, system retrieves the JWT token and stores in App for future requests for that user.

However, we would also like to add an API key in addition to this JWT token call so we only service requests coming from a valid key.

What is the recommended approach/library/package to use alongside the JWT middleware?

0 likes
2 replies
Palak27's avatar

for api use can generate one random key for each user and store into database when send request you can validate token of particular user.

hanzanati's avatar

thanks for the reply, but I was more talking about using a secondary key in addition to JWT so only our app can make calls as it's not a public API.

Please or to participate in this conversation.