Skip to main content
Solved

How to get token by using httpcaller?

  • February 1, 2023
  • 1 reply
  • 190 views

limo
Supporter
Forum|alt.badge.img+8
  • Supporter

There are some postings on this but it does not work for me yet:

I am trying to contact an external API via HTTP POST to get a token back.

It already works with python. But we wanna integrate the workflow in fme server and Iam sure it will work with fme.

 

Python script:

# Parameter_____
base_url = 'https://apieco.eco-counter-tools.com'
api_key = 'XXX'  # Base64 encoded secrets
 
 
# Tokenabruf
def get_token(url, api_key):
    header = {
        'Content-Type':'application/x-www-form-urlencoded',
        'Authorization''Basic ' + api_key 
             }
    r = requests.post(url + "/token", headers= header, data={'grant_type''client_credentials'})
 
    answer = json.loads(r.text)
    token  = answer['access_token']
    return token

HTTPCaller:

image 

Erorr Message: 

HTTP/1.1 415 Unsupported Media Type

 

 

Which mime type should I use for the grant_type: client_credentials?

Best answer by limo

Ah I got it:

I have to define "grant_type= client_credentials" inside the parameter for query string

 

image

View original
Did this help you find an answer to your question?

1 reply

limo
Supporter
Forum|alt.badge.img+8
  • Author
  • Supporter
  • Best Answer
  • February 1, 2023

Ah I got it:

I have to define "grant_type= client_credentials" inside the parameter for query string

 

image


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings