Hi
Can anyone assist with WLanguage syntax (Ver 26) to sign a JSON Web Token.
The VB syntax uses Jose.io :-
' create the signed JWT assertion
Dim token = Jose.JWT.Encode(payload, rsaCsp, Jose.JwsAlgorithm.RS256, extraHeaders)
i sourced and translation a snippet from Patrice in the the French forum (JSON Web Tokens (JWT - RFC 7519 - Signature) with 2 procedures that looks like (below)::-
If anyone is familiar with this, could you please let me know if this is the correct approach, or suggest some other syntax.
Many thanks in advance.
Regards,
Derek
PROCEDURE
JWTSignature(sHeader is a string,
sPayload is a string,
sSecret is a string)
sRes is a string
sData is a string
bufBuf is a Buffer
bufBuf = HashString(HA_HMAC_SHA_256, sHeader + "." + sPayload, sSecret)
sRes = UTILBase64EncodeURL(bufBuf)
RETURN
//--------------------------------------------------------------------------------
PROCEDURE
UTILBase64EncodeURL(LOCAL sData is string)
sRes is string = Encrypt(sData, "", compressNone + cryptNone, encodeBASE64)
sRes = Remplace(sRes,"/","_")
sRes = Remplace(sRes,"+","-")
sRes = Remplace(sRes,CR,"")
i is int
i = Taille(sRes)
WHILE i>0 _ET_ sRes[[i]]="="
i-=1
END
RETURN Left(sRes,i)
//-------------------------------------------------