Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

expiry data of jwt token

function isTokenExpired(token) {
  const payloadBase64 = token.split('.')[1];
  const decodedJson = Buffer.from(payloadBase64, 'base64').toString();
  const decoded = JSON.parse(decodedJson)
  const exp = decoded.exp;
  const expired = (Date.now() >= exp * 1000)
  return expired
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #expiry #data #jwt #token
ADD COMMENT
Topic
Name
3+8 =