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

Unknown function 'jwt_encode'

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

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

Hello,

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

Top Kudoed Authors