pythonjwtalteryx

Alteryx Error generating JWT token with python tool - NotImplementedError: Algorithm 'RS256


I am having issues creating an Alteryx workflow that encodes a JWT token with the RS256 algorithm in the python tool.

Here is my code:

#################################
from ayx import Alteryx
from ayx import Package
import pandas
##Package.installPackages(package="cryptography",install_type="install --proxy proxy.server:port")  
##Package.installPackages(package="pyjwt[crypto]",install_type="install --proxy proxy.server:port")
import jwt
from io import StringIO


#################################
table = Alteryx.read("#1")


#################################
print(table)


#################################
id = table.at[0, 'id']


#################################
url = table.at[0, 'url']


#################################
key = table.at[0, 'key']


#################################
exp = table.at[0, 'exp']


#################################
exp = int(exp)


#################################
nbf = table.at[0, 'nbf']


#################################
nbf = int(nbf)


#################################
encoded = jwt.encode({"iss": id, "aud": url, "exp": exp, "nbf": nbf}, key, algorithm='RS256')


#################################
s=str(encoded,'utf-8')

data = StringIO(s) 

df=pandas.read_csv(data,header=None)


#################################
Alteryx.write(df,1)

The problem is when I try to encode a JWT using the RS256 algorithm: encoded = jwt.encode({"iss": id, "aud": url, "exp": exp, "nbf": nbf}, key, algorithm='RS256'), It spits back out this error message: NotImplementedError: Algorithm 'RS256' could not be found. Do you have cryptography installed?

the Cryptography package should be installed since I specified [crypto] when choosing the package name: pyjwt[crypto] – source: Installation — PyJWT 2.7.0 documentation. I also tried installing it separately by adding ##Package.installPackages(package="cryptography",install_type="install --proxy proxy.server:port") but still got the same error.


Solution

  • the solution for this was documented here.

    I simply followed the instruction for 2021.1.4+ and installed pyjwt[crypto]