GeoEvent input connector using token authentication

2220
8
03-01-2019 12:51 AM
Hwa_SaupLee
New Contributor III

I need to configure a JSON poll connector using token.  First I need to get a token using POST request and then pass the token to the different url to get jSON data.  I think it is a very typical process: get a token from token url and get json data using the token authentification. But it is unclear in Geoevent how to do.  

Any idea or sample?  

Tags (1)
8 Replies
EarlMedina
Esri Regular Contributor

Hi,

A bit more context would help - do you mean that you're polling a secured external website for JSON?

0 Kudos
Hwa_SaupLee
New Contributor III

Hi.

Yes. It is polling json from external website. First I need to get a token using post request. Second i need to pass the token to get json data using get request.

Get Outlook for Android<https://aka.ms/ghei36>

0 Kudos
EarlMedina
Esri Regular Contributor

I'm not positive of an out-the-box solution, but conceptually you should be able to create a lightweight application that:

  • Obtains the token
  • Sends a request to the website with the required token
  • Sends the response to GeoEvent

In that case, you'd use the 'Receive JSON on a REST Endpoint' input connector.

0 Kudos
RasmusJensen
New Contributor II

I have the exact same issue. I am trying to get data from the GPSGate REST service.
The use of this service requires authentication, and this is done using a token, which you have to get using a username and password. 
There is a service where you can get your token using a POST request sending username/password to the Token service and get a Token back and then use that token for authetication in the following requests

See this site for examples: Use REST API for getting Events – GpsGate Support 

The thing I can't figure out is how to either send the token in the " HTTP Authorization header " in the following requests. Preferably I would like to do all this inside GeoEvent.
Initially I thought I could just send name/value pairs the Header Parameter of the Poll an External Website for JSON input connector.

Best Regards,

Rasmus

0 Kudos
mody_buchbinder
Occasional Contributor III

Reopen thsi issue, we have this problem too.

I found this https://github.com/Esri/http-inbound-auth-token-for-geoevent from 2017

Does it solve the problem? Will it work in 10.8.1?

Thanks

AlexLeonov
New Contributor II

Good day!

Did you solve the issue with auth token authorization for input connector for geoevent?

Thanks

0 Kudos
RJSunderman
Esri Regular Contributor

The pattern suggested above by @EarlMedina is what you'll need to follow if you're limited to what you can configure out-of-the-box. GeoEvent Server inputs which send HTTP/GET requests to query an external REST API for data need to incorporate all necessary data in the request URL as query parameters. Multiple requests to first obtain authorization and incorporate an authorization token in a second request are not something you can configure out-of-the-box. Available GeoEvent Server inbound connectors do not support the concept of authorization token expiry and refresh (like you might find when working with an authorization protocol or framework such as OAuth).

An input such as the Receive JSON on a REST Endpoint, on the other hand, hosts a REST endpoint to which external clients can HTTP/POST data. GeoEvent Server does not offer any sort of authorization or client authentication in this case. If the client can reach the GeoEvent Server's endpoint, the client is allowed to make an HTTP/POST request with a data payload.

You can develop a "relay" or "bridge" using any scripting or development SDK you are familiar with to handle the multiple steps required in a publisher/subscriber pattern. The bridge you develop between the data provider and GeoEvent Server would be responsible for sending a request to obtain use authorization and then sending periodic requests using that token to obtain data. The data response could then be relayed to GeoEvent Server via HTTP/POST. The bridge you develop in this case would also handle use authorization token expiry and periodic token refresh.

Looking at the contributor history it does not appear that the "Sample Http Inbound Transport" referred to above (http-inbound-auth-token-for-geoevent), available on GitHub and developed for polling a REST endpoint, is being actively maintained. I cannot say whether or not the sample transport can readily be incorporated into an inbound connector, how such a connector was intended to be used, what assumptions it might make, or whether it will work with a particular release of ArcGIS Enterprise.

@EricIronside  @MorakotPilouk 

0 Kudos
EricIronside
Esri Regular Contributor

Hey All,

As @RJSunderman mentioned, this two-factor authentication model is not supported by GeoEvent Server OOTB. The reason it is not OOTB is that there are an infinite number of ways this could be supported (similar to using dates or version numbers in the polling request) so there is no way it can be done in a reasonable manner that meets most needs. However, this is a pattern we have seen and implemented in several of the custom GeoEvent Gallery Connectors. So it can be done by creating a custom Transport using the GeoEvent Server SDK.

If you don't want to write a custom Transport, then a second option would be to use @RJSunderman's suggestion of using a bridge to push data to GeoEvent Server. This could be written in any language/implementation you are most comfortable with.

Finally, if you don't want to write a bridge you could use python to develop a scheduled script that updates the token within GeoEvent Server on a periodic basis.  For example, if your token is good for 24 hours, you could schedule a python script (using Windows Task Scheduler for example) to run every 20 hours and update the token.  If this is the route you are interested in taking pleas see this blog entry: Scripting tasks using the GeoEvent Admin API - Update Inputs 

For even more information on what you could do with the GeoEvent Admin API, please see @RJSunderman's blog that presents a number of examples: Scripting tasks using the GeoEvent Admin API 

0 Kudos