I have the following code which I use to acquire a secret, use secret to log into portal and download a csv table. This works ok outside a function.
import pa