How to handle JWT.exp time?

Isaac
console.log('DEBUG::+jwtDecode(token).exp', +jwtDecode(token).exp); //1534820211

console.log('DEBUG::try', new Date(+jwtDecode(token).exp).toISOString());
//DEBUG::try 1970-01-18T18:20:20.211Z

I'm having a token with value 1534820211 and when I try to convert it using toISOString() it gives me year 1970-01-18T18:20:20.211Z.

But when I decode the same token at jwt.io, and mouse hover over exp, it shows 2018-08-21.... which is huge difference. I have also tried to pass jwtDecode(token).exp into moment and using format, still return me datetime in 1970xxxx.

moment(jwtDecode(token).exp).format();
31piy

The value you have is seconds from epoch.

JavaScript Date constructor (and moment constructor as well) accepts value in milliseconds from epoch. Multiply the number by 1000, and your code should work fine:

var exp = 1534820211 * 1000;
console.log(new Date(exp));

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to generate JWT exp claim with java-time?

分類Dev

How to handle time.time() in Python?

分類Dev

How should I handle exceptions raised in @jwt_required decorator? (in flask-jwt-extended)

分類Dev

how to handle time for different components in pygame

分類Dev

Handle jwt auth errors in laravel

分類Dev

How do I handle modified time with http.ServeContent()?

分類Dev

JWTのexp(有効期限)クレームの形式

分類Dev

JWTのexp(有効期限)クレームの形式

分類Dev

JWT.exp時間を処理する方法は?

分類Dev

JWTデコードが無効なexp値で失敗する

分類Dev

How do I handle real time search of a database in a Django web app?

分類Dev

How can to handle the error: Run-time error '53' File not found

分類Dev

JWTのExpおよびIatを正しく設定できません

分類Dev

longを比較してJWT expフィールドをチェックします

分類Dev

How to handle type of an iterator?

分類Dev

How to handle Circle in WKT?

分類Dev

How to handle hyperlink in css?

分類Dev

How to declare handle array

分類Dev

How to handle this validation context?

分類Dev

How to handle the last case?

分類Dev

How can handle tensorflow

分類Dev

How to handle responses in Angular?

分類Dev

How to handle multiple Ciphers

分類Dev

How to handle hooked WSARecv

分類Dev

How to handle null in Anorm

分類Dev

How to handle JSON data?

分類Dev

How to handle ! with enabledelayedexpansion in batch

分類Dev

How to handle exceptions with builders

分類Dev

How to handle OutOfMemoryException