Using HTTPoison to get access token

Hello All,
I am new to Elixir and so far having fun learning. I am trying to call a REST API using HTTPoison and am running into an Issue.

Here is what I am trying to do.

I need to generate an access token by sending a POST request to the authorization server:

This is the curl command to get the access token.

curl “
-H “Content-Type: application/x-www-form-urlencoded”
-d “grant_type=client_credentials&client_id={client_id}&client_secret={client_secret}”

I want to use HTTPoison to get the access token which will then be used to pull the data.

Anyone has any example how to convert the curl to HTTPoison?


As a starting point, try this online converter from cURL to several different languages. Elixir is included.


Here’s how I get the token:!(
      grant_type: "client_credentials",
      client_id: @client_id,
      client_secret: @client_secret
1 Like

Thank you @nidu and @dimitarvp. I was able to use the!.