How to authenticate API and get temporary token

I want to use the API of CurrencyCloud, but need help on how to authenticate and get a temporary token.

Here are their instructions

Here is my credentials for their sandbox:
login_id : hendrik@withreach.com
api_key : 9e4305c54d2bb4e819b61ef3709bdf012b778bb6af726fcef524942c4d293d58

Any help would be appreciated!

Hello!

It appears that CurrencyCloud is using some kind of a ‘home-brewn’ OAuth scheme (e.g. one that does not follow the RFC6749) and this means we can’t use built-in Easymorph OAuth tools and have to construct some workaround to manage tokens manually. This would be somewhat inconvinient, but it can be done nevertheless.

The first way to do this, one that’s more suitable for server-side unsupervised execution, is to make separate ‘get token using credentials’ action and use this action output to set X-Auth-Token header in all subsequent CurrencyCloud calls. The downside of this approach is that you are getting a new token for each run, and CurrencyCloud appears to have strict rate limits for issuing new tokens.

  1. Create Web Location data connector and set CurrcencyCloud base url

  1. Add Web Request action to your project and select newly created Web Location connector, POST request method, input endpoint path (authenticate/api) and enter your login and key in Body section (don’t forget to select Form encoding):

  1. One more thing - in Web Request action settings, click Response tab and pick ‘Return response as the action result’

  1. Filter the response - keep only Response-Body column and parse it as JSON using Parse JSON action

image

  1. You should get the resulting table with one column that contains a token you obtained as an authentication result. Now we need to pass this token to API actions, and to do this we create a module (in my example named Query_CurrnecyCloud) and create auth-token and endpoint parameters to be specified during module invocation.

image

  1. In Query_CurrnecyCloud module, create similar Web request action with our Web Location connector, select endpoint parameter to be used as a Path and add new X-Auth-Token item in Headers section, and select auth-token module parameter to be used as this header value. Also, check Return response as action result in Response tab of Web Request action.

  1. Add filtering actions to pull data from endpoint response - keep Response-Body column and add Parse JSON action

  1. And, finally, we have our module ready to use. To call this module with parameters supplied by table values, append Iterate action in the main module right after our authentication actions, set up it to use our Query_CurrnecyCloud module and specify that auth-token parameter value should be taken from auth_token column, and endpoint parameter should be specified manually - that’s a name of CurrencyCloud API endpoint you want to call, in my example I set it to accounts/current to look at our authorized account properties.

The second way to do this, without iterations etcetera is to call authenticate/api manually, copy response auth_token value and save it to Web Location connector directly - to the headers section. And this should be done manually each time a token expires.

Finally, please, don’t post your credentials to the public :slight_smile: I understand that this is only a sandbox account now, but just to be sure.

Absolutely bloody marvelous!

Thanks for the detailed instructions and screenshots. Without those, I would not have been able to solve this.

You’re welcome!