#1 2021-05-10 11:14:30

marmor
Member
Registered: 2021-05-10
Posts: 2

Generate new JWT Token

I need to generate a JWT Token from scratch and then sign it with HS512.

The documentation only includes the creation and verification based on an already existing token.

Any hints / code example?

Offline

#2 2021-05-10 12:07:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,280
Website

Re: Generate new JWT Token

The TJWTAbstract and inherited classes are generators, not token instances.
The TJWTAbstract.Compute actually generates and signs a new token.
What do you call "token"?

Offline

#3 2021-05-10 13:55:53

marmor
Member
Registered: 2021-05-10
Posts: 2

Re: Generate new JWT Token

So far i have used jose-jwt components to generate and sign JWT in REST Client app. Since Mormot has classes built into the JWT, I wanted to drop them.
I need to generate a string with JWT Token

Offline

#4 2021-05-10 16:33:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,280
Website

Re: Generate new JWT Token

So just use TJWTAbstract.Compute with the proper sub-class as TJWTHS512 for HS512.

BTW I find it unsual to sign the JWT on the client side - but anyway...

Offline

Board footer

Powered by FluxBB