Hey y’all,
Recently I needed to generate JWTs inside AL and couldn’t find a ready-to-use snippet. So I put one together, published it as a GitHub Gist, and figured: maybe it’ll save someone else a bit of time in the future.
What’s in the Gist
The Gist contains a small AL codeunit to generate JSON Web Tokens (JWTs).
For those not familiar: JWT stands for JSON Web Token – a compact, URL-safe way to represent claims between two parties. They’re widely used for authentication and authorization in web services.
Highlights of the snippet:
- Creates a standard JWT header (
alg: HS256
,typ: JWT
). - Lets you pass in custom claims for the payload.
- Adds useful time claims like
exp
,iat
, andnbf
. - Handles Base64 URL encoding correctly.
- Includes a helper for using the generated token in HTTP Bearer authentication.
Check it out here: gist.github.com.
A Note on Kiota for AL
Some of you might wonder whether Kiota for AL is still alive. The answer is yes! Development is a bit slow at the moment because of other responsibilities, but it’s definitely not forgotten. I’m still receiving feedback from the community and iterating on it whenever time allows.
How to Use It
- Copy the JWT codeunit from the Gist into your project.
- Provide your secret key and payload claims.
- Call
GenerateToken
and attach it as a Bearer token in your HTTP requests.
That’s it: a small utility, hopefully useful if you ever need to roll your own JWTs in AL.