Miyako 4d-Plugin JWT (Json Web Token)

Hi,

Is anyone using the plugin JWT Plugin of the excellent Keisuke MIYAKO ? https://github.com/miyako/4d-plugin-jwt/

It seems I can’t make it work to generate a web token (I need the ES256 encryption mode).

I manage to call the JWT Timestamp methods without any problem but the JWT Sign method kept returning an empty string.

Anyone tried this plugin ?

$header (generated from a Json Object) :
{‘alg’:‘ES256’,‘typ’:‘JWT’,‘kid’:‘AZERTYUIOP’}
$payload (generated from a Json Object) :
{‘iat’:‘1540007192800’,‘exp’:‘1541058394043’,‘iss’:‘maps.com.gesprojet’}
$key string from a base64 string in a P8 certificate associated with the KeyID:
‘MIGTAgEZCBMGSyq…’

Then I call the method :
$return:=JWT Sign ($header;$payload;$key)

$return always empty even trying the alg ‘none’ argument.

One thing that could potentially matter is the key is 200 bits length which shouldn’t be a problem in ES256.

‘generated from a Json Object’ should be read as Json stringified string obtained from an object.

$key should not be base64 string. it should be plain text that starts with ‘-----BEGIN PRIVATE KEY-----’

$header looks OK.

$claim (or $payload) should typically have the properties aud, exp, iat, iss, scope, sub.

some services expect iat and exp in milliseconds, come expect seconds (see my other post).