15
Views
7
Comments
[JwtGenerator] Jwt Generator > GenerateJwtFromPemString() - Missing required claim: 'iss'
Question
JwtGenerator
Forge asset by ACA-IT

GenerateJwtFromPemString() has an input parameter 'scope' and no matter what format I pass the JSON in I get the error: 'OS-ELRT-60008 - System.Exception: Failed to generate or validate JWT: Missing required claim: 'iss' in generated token.' Have tried:

"""iss"":""procure'"",""sub"":""procure"",""iat"":""1767960163"",""nbt"":""1767960043"",""exp"":""1767960763"",""groups"":[""PortalUsers""],""acc_nums"":[""635""]}", which is how the JsonSerialise widget formats it. Also tried many other variations but get the same error each time. Does anyone know the correct way to format the scope value for this plugin?

2021-10-09 07-57-44
Stefan Weber
 
MVP

Hi Joe,

I'm not using the JwtGenerator component, because ODC has builtin actions to generate a JWT, but the error indicates that you need to provide a issuer value (iss). 

regarding the scope parameter: Scopes are space delimited values. scopes are defined (and checked) at the API where the generated token is used. Scope value can be for example "Contact.Read Contact.Write Contact.Delete" telling the API that your token includes potential permissions to read, write and delete contacts. 

UserImage.jpg
Joe Kelly

Hi Stefan,

Thanks for your response. I am not quite sure how I would pass the information as a scope then. This is the information we need to pass:

{ "iss": "procure", "sub": "procure", "iat": 1722589451, "nbf": 1722589331, "exp": 1722590051, "groups": [ "PortalUsers" ], "extsecprops": {    "acc_nums": [        1001    ] } } 

Do you know how I would convert this from JSON into a scope?

2021-10-09 07-57-44
Stefan Weber
 
MVP

The Json you provided is a complete JWT payload. scope is optional in JWT, so if you don't have one you shouldn't provide one.

But the payload alone is not a complete JWT. you would also need the Header and most likely the computed signature. You would nee a private key in either PEM or JWK format to sign the header + payload.

UserImage.jpg
Joe Kelly

Hi Stefan,

Do you know how we would define the issuer then because the plug in throws an error advising we're not sending the issuer.

2021-10-09 07-57-44
Stefan Weber
 
MVP

Actually I don't know because I do not use this Forge component at all. Sorry. Check if the action has an input property Iss or Issuer where you can set a value.



UserImage.jpg
Joe Kelly

Hi Stefan,

Thanks I do understand a little better now. Think maybe the plug in isn't correct for what we're trying to do.

2023-10-16 05-50-48
Shingo Lam

I think you should learn how the generator work first. Please visit this for more detail https://www.jwt.io/

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.