Alot of the answers on here are great - JWT tokens are indeed a standard for authentication, especially for OAuth. If you are using either JavaScript or PHP for your application, here is an open-source library I wrote named "QuickJWT" that may solve your basic JWT needs. I've been having problems finding suitable libraries myself to deal with JWT and so I decided to write one that makes encoding, decoding, and validating JWT tokens easier. Usually, there's a lot of code involved, so I made QuickJWT simpler to work with.
There's examples on how to encode a payload and sign it with a secret key. Hope this gives you an idea of how to work with JWT tokens and decode their payloads for details. Take a look at QuickJWT: