Auth0 Home Blog Docs

Can you give a sample log in program using JWT?



i’m having a trouble understanding JWT. can you help me?


Sure @pilipinass123 - there are a few good resources for getting started with JWT:


A [JWT] ( defines a way to transfer data between two parties. It consists of three parts separated by dots (.), which are:

  • Header
  • Payload
  • Signature

Therefore it typically looks like: xxxxx.yyyyy.zzzzz You can use to decode it and see the claims it contains.

To get an id token or an [access token] ( you can use Auth0.js, Lock.js, [the Authentication API] ( or any other library for another language. A common use would be to use the [hosted login page] ( with Auth0.js and a SPA client as:

<script src=""></script>
var webAuth = new auth0.WebAuth({
  domain: {YOUR_AUTH0_DOMAIN}, 
  clientID: {SPA_CLIENT_ID},
  audience: {API_AUDIENCE},
  redirectUri: '{CALLBACK_URL}', 
  scope: 'openid profile',
  responseType: 'token id_token'

On the callback from the authorize request, you can use parseHash to get the JWT tokens:

webAuth.parseHash(function(err, authResult) {
  if (authResult) {
    var accessToken = authResult.accessToken;
    var idToken = authResult.idToken;

     // any other logic...

You can see more detailed information about JWTs [here] ( and you should also check [OIDC conformant clients] (, [OIDC authentication] ( and [how to call your APIs with the access token] (