Question
· Mar 17, 2023

JWTToObject

Goodday,

I would like to Validate token signature with public key i have in pem format, i am using below  code but i get error message. Could you please tell me what i am doing not right? FOUT #5002: Caché fout : <DIRECTORY>zLinkToFile+2^%Stream.FileBinary.1 *-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMI ...

hier is my code

Method ValidateTokenWithPublicKey(jwt As %String) As %String
{
   
     Set tFile=##Class(%File).%New("c:\Kety\publicKey.pem")
    Do tFile.Close()
    Set tStatus=tFile.Open("RU")
    $$$ThrowOnError(tStatus)
    Set tPublicKey=tFile.Read()
    Do tFile.Close()
    
    set sc = ##class(%OAuth2.JWT).JWTToObject(jwt,,tPublicKey,.JOSE,.Body)
    if ('sc){
      set errMsg = $System.Status.GetErrorText(sc)
      $$$TRACE(..classId _ "- Error validateJWT:" _ errMsg)
    }
    $$$TRACE(..classId _ "- validateJWT:" _ JOSE)
}
 

Kind Regards

Ed

Product version: IRIS 2020.1
$ZV: build 217 Path 1 for windows x86-64
Discussion (1)2
Log in or sign up to continue