The Community is now in read-only mode to prepare for the launch of the new Flexera Community. During this time, you will be unable to register, log in, or access customer resources. Click here for more information.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unknown function 'jwt_encode'

ves_qad_com
By
Level 2

I try to create jwt token using jwt_encode($algorithm, $payload, $key, $header_fields) (from https://docs.rightscale.com/ss/reference/rcl/v2/ss_RCL_functions.html#miscellaneous-jwt_encode)
But when I upload CAT file to Designer I got - Unknown function 'jwt_encode' at line 16, column 16 Use valid Cloud Application Template syntax


My code is similar to:

$payload = {"target_audience": $some_endpoint, "iss": "email", "sub": "email", "aud": "url", "exp": 1644320037, "iat": 1644320037}

$key = "key"

$header = {"alg": "RS256", "typ": "JWT"}


$jwt = jwt_encode("RS256", $payload, $key, $header)

COULD YOU HELP ME WITH THAT?
Thank you, Vasyl Stavinskyi

(3) Replies

douglaswth
By
Flexera Alumni

I'd have to see more of the file, but I suspect the problem may be that your code is outside of an  RCL definition and therefore cannot be parsed as RCL code. An RCL definition looks like:

define do_something($some_endpoint)
  $payload = {"target_audience": $some_endpoint, "iss": "email", "sub": "email", "aud": "url", "exp": 1644320037, "iat": 1644320037}
  $key = "key"
  $header = {"alg": "RS256", "typ": "JWT"}

  $jwt = jwt_encode("RS256", $payload, $key, $header)
  ...
end

Actually I have the same separated method in my CAT file

Juliaroby45
By
Level 2

Hello,

First of all check your function availability, Syntax Or Context Error. Check the RightScale  Documentation, Validate Your CAT code.

Top Kudoed Authors