Question

PythonCaller rest API using oauth2 web connection

  • 5 March 2020
  • 1 reply
  • 17 views

Hi,

I'm trying to call an API endpoint using PythonCaller but this endpoint requires authentication.

I made it work by first (in the init) connect to the web connection and get the token than send it to the def input and used the token in the header of my endpoint call.

My question is: is there a way to get this token from one of my web connection set in the Tools->FME Options->Web Connections (or either from a published parameter configured with one of them)?

 

The idea is to use the PythonCaller as a HTTPCaller which uses Authentication

 

thank you


1 reply

Userlevel 4

As far as I know, there is no way of retrieving the tokens etc from the FME Web Connections.

If you want to do OAuth from Python in FME, you may want to look into using some of the existing modules that will handle the brunt of the work for you: https://oauth.net/code/python/

My first instinct would be to use the excellent Requests module with the corresponding OAuth libraries.

This would enable you to get your own OAuth token and to use it for the subsequent API calls.

Reply