# How to authenticate API and get temporary token

**URL:** <https://community.easymorph.com/t/how-to-authenticate-api-and-get-temporary-token/2647>\
**Category:** General Q&A\
**Created:** [April 15, 2021, 2:42am UTC](https://community.easymorph.com/t/how-to-authenticate-api-and-get-temporary-token/2647 "2021-04-15T02:42:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hendrik\_Lombard](https://community.easymorph.com/user_avatar/community.easymorph.com/hendrik_lombard/32/1254_2.png) [@Hendrik\_Lombard](https://community.easymorph.com/u/Hendrik_Lombard)\
**Post date:** [April 15, 2021, 2:42am UTC](https://community.easymorph.com/t/how-to-authenticate-api-and-get-temporary-token/2647/1 "2021-04-15T02:42:10Z")

</div>

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

Here are their instructions  
[https://www.currencycloud.com/developers/docs/item/login/](https://www.currencycloud.com/developers/docs/item/login/)  
[https://www.currencycloud.com/developers/cookbooks/authenticating/](https://www.currencycloud.com/developers/cookbooks/authenticating/)

Here is my credentials for their sandbox:  
login\_id : [hendrik@withreach.com](mailto:hendrik@withreach.com)  
api\_key : 9e4305c54d2bb4e819b61ef3709bdf012b778bb6af726fcef524942c4d293d58

Any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![olysak](https://community.easymorph.com/letter_avatar_proxy/v4/letter/o/aeb1de/32.png) [@olysak](https://community.easymorph.com/u/olysak)\
**Post date:** [April 15, 2021, 9:22am UTC](https://community.easymorph.com/t/how-to-authenticate-api-and-get-temporary-token/2647/2 "2021-04-15T09:22:18Z")

</div>

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

 ![image](https://community.easymorph.com/uploads/default/original/2X/1/157b4ef74ad8dbb8d7f9d53d74d66977fb35b847.png)

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):

 ![image](https://community.easymorph.com/uploads/default/original/2X/4/419988746559b3c353dca1bf4302bc3a8df518ba.png)

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

 ![image](https://community.easymorph.com/uploads/default/original/2X/d/d1c84352458f492f143d7ff0bd9fd2b0ce671c3d.png)

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

 ![image](https://community.easymorph.com/uploads/default/original/2X/6/60aca941d356dbdace5e3002fa83029482c2053b.png)

 ![image](https://community.easymorph.com/uploads/default/original/2X/d/d0e684cf31150e95c1c0cff43c6114bedfc6b727.png)

 ![image](https://community.easymorph.com/uploads/default/original/2X/2/21e57213b78462745f8660137a5b1ee2655759e5.png)

 ![image](https://community.easymorph.com/uploads/default/original/2X/0/030dba4b4848f1e290fbdb8e9565bd2c6400db76.png)

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](https://community.easymorph.com/uploads/default/original/2X/7/727f5ee5f7797d0882d48fc5d7fa181469ed043f.png)

 ![image](https://community.easymorph.com/uploads/default/original/2X/4/41d977ee4661c8756efcc3392c4b8545eb48fe11.png)

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.

 ![image](https://community.easymorph.com/uploads/default/original/2X/2/24686539371d292909e1bfbf9b33509fba96d6bc.png)

 ![image](https://community.easymorph.com/uploads/default/original/2X/6/6baeaaf20a14614489dc3f256c63b4f689020acd.png)

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

 ![image](https://community.easymorph.com/uploads/default/original/2X/5/5fb4617c2bcf1ce5b4503dde23ebbe9bf987f4b3.png)

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.

 ![image](https://community.easymorph.com/uploads/default/original/2X/3/351b4f56a2761d3521b36f04fe965c485cf511f9.png)

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 🙂 I understand that this is only a sandbox account now, but just to be sure.

---

<div class="post-metadata">

**Author:** ![Hendrik\_Lombard](https://community.easymorph.com/user_avatar/community.easymorph.com/hendrik_lombard/32/1254_2.png) [@Hendrik\_Lombard](https://community.easymorph.com/u/Hendrik_Lombard)\
**Post date:** [April 15, 2021, 2:30pm UTC](https://community.easymorph.com/t/how-to-authenticate-api-and-get-temporary-token/2647/3 "2021-04-15T14:30:21Z")

</div>

Absolutely bloody marvelous!

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

---

<div class="post-metadata">

**Author:** ![olysak](https://community.easymorph.com/letter_avatar_proxy/v4/letter/o/aeb1de/32.png) [@olysak](https://community.easymorph.com/u/olysak)\
**Post date:** [April 15, 2021, 3:29pm UTC](https://community.easymorph.com/t/how-to-authenticate-api-and-get-temporary-token/2647/4 "2021-04-15T15:29:35Z")

</div>

You're welcome!
