Question

How to get Token (Bearer) code to use for connect API?

  • 26 March 2021
  • 7 replies
  • 85 views

Badge

I am a GIS engineer who wants to learn how to access data via API. I have tested a bit and managed to connect to simple APIs. Now trying to connect to a Swagger API and can't get the token to connect to the API. I have received a key and can access via website if I enter code under Authorize. I want to connect to the API using FME, but do not know how to access the token code. Can anybody help me?

PowelMeldingAuthorizations


7 replies

Userlevel 5
Badge +29

In the httpcaller, you needs to specify an Authorization Header with the name "Authorization" and the value "Bearer <token>"

 

 

Badge

TokenThank you, and sorry for late response, I have been on vacation. I don't have token value, just a key(value) to use for getting token value. Am I wrong thinking I have to first get token value and use this code in Authoizatin Header, like you showed me, with the token code after Bearer?

 

Userlevel 3
Badge +13

Hello @laila72​ , it may be possible to build a web service and then use FME to connect to it without manually obtaining the token. Is there any API documentation (specifically on authorization or authentication) available for this? We have some resources on web services here: https://community.safe.com/s/article/Web-Connections-and-FME. Hope this helps, Kailin

Userlevel 5
Badge +29

TokenThank you, and sorry for late response, I have been on vacation. I don't have token value, just a key(value) to use for getting token value. Am I wrong thinking I have to first get token value and use this code in Authoizatin Header, like you showed me, with the token code after Bearer?

 

Yes, you need to generate that token somehow. I've had a quick look at what i think is the REST API (https://meldingapi.powel.net/swagger/index.html?urls.primaryName=Powel%20Melding%20API%20v2) and there doesn't seem to be any call exposed to enter credentials and generate a token. If you have a user name and password you could try using basic authentication in the HTTP Caller (under Use Authentication). If that doesn't work, i'd touch base with the API provider for some help

Badge

Thank you both :-) No I found some more information. I can access date using powerB (web connection), but the same parameters in web connection FME don`t work. Any idea why?

WebConnection

Userlevel 5
Badge +29

Thank you both :-) No I found some more information. I can access date using powerB (web connection), but the same parameters in web connection FME don`t work. Any idea why?

WebConnection

Thats the interface to build a WebConnection, you need to use a HttpCaller

Badge

Hi again, and thank you for your answer. I got access with HTTPCaller, the solution is username en key value in the header. GetData

Reply