Dev Space

Customize & extend the power of Alteryx. SDKs, APIs, custom tools, and more!
Don't forget to submit your entry for the Excellence Awards by October 30! | Need more information about the program? Check out the blog here

Write Configuration Data from Python SDK

Highlighted
5 - Atom

Hi

 

I have written an HTML + Python Oauth tool for a platform.  I Oauth in the HTML fine and it saves the auth token and refresh token which is made available to the Python.  The issue is that once the access token expires, I refresh it.  The refreshing brings with it a new refresh token which I have to use for subsequent refreshes.  I need to replace the (now defunct) refresh token stored in the config with the new one.  How do I write configuration data back to the tool config, or should I persist this elsewhere?

 

Thanks

Highlighted
Alteryx
Alteryx

Hello @rendezz , 

 

Have you considered keeping all of the token logic on the UI side? I don't believe that we support writing from the engine to the UI at this time-I haven't seen it done. 

 

-Tasha

 

 

Highlighted
5 - Atom

Thanks

 

Unfortunately, once you start using the tokens, the original ones become invalid, so if you use them in the engine, the UI ones need to now get re-authed, which invalidates the ones in the engine etc.

 

But I hear you about not being able to write config from the engine, that is what I have found as well.  I am thinking of setting up an online service which both UI and engine can access to manage and persist tokens.

 

Thank you for your input.

Highlighted
Alteryx
Alteryx

You can update the config XML of the tool from the backend by doing:

engine.output_message(
    tool_id,
    Sdk.Status.update_output_config_xml,
    updated_xml_string,
)
Highlighted
5 - Atom

Thank you, I will go ahead and try this.