Forum Discussion

PeterMattsson's avatar
6 years ago

Custom HTTP Integrations and refresh/update oauth2 tokens

Hi,

Has anyone been faced with trying to create a custom http integration towards a system that need to refresh oauth2 tokens to be able to connect. The same way you need to refresh the tokens for Logic Monitor when connecting.

  • Hey @PeterMattsson,

    I think we've had folks run into this before, it sounds familiar. Tokens can be used pretty extensively in a Custom HTTP Integration, so in theory, you could do something like:

    • Write a scripted DataSource (applied to a Collector or other 'dummy' resource) that goes through the OAuth2 token refresh flow with the external API (we can help find an example of an OAuth flow if needed)
    • Have this same scripted DataSource reach out to the LogicMonitor API and set the token as a property at the root of the account / wherever (auto.integration.api.key)
    • Use the custom property value as a token in the API authentication of your Custom HTTP Integration (##auto.integration.api.key##)

    Takes a little bit of work - but should get the job done. Hope that helps.

    Cheers,

    Kerry

  • Thank you very much and sorry for the late response. We will surely try this.

     

    Cheers,

    Peter

  • On 12/9/2019 at 10:53 PM, Kerry DeVilbiss said:

    Hey @PeterMattsson,

    I think we've had folks run into this before, it sounds familiar. Tokens can be used pretty extensively in a Custom HTTP Integration, so in theory, you could do something like:

    • Write a scripted DataSource (applied to a Collector or other 'dummy' resource) that goes through the OAuth2 token refresh flow with the external API (we can help find an example of an OAuth flow if needed)
    • Have this same scripted DataSource reach out to the LogicMonitor API and set the token as a property at the root of the account / wherever (auto.integration.api.key)
    • Use the custom property value as a token in the API authentication of your Custom HTTP Integration (##auto.integration.api.key##)

    Takes a little bit of work - but should get the job done. Hope that helps.

    Cheers,

    Kerry

    @Kerry DeVilbiss,

    I am trying to use this approach and it does not seem like the property token works in the http custom header value field. 

    Have you been able to use this approach?

    Thanks

    Ross

  • Hey @Kerry DeVilbiss -

    You’d mentioned that you might have a DataSource example for performing an OAuth2 token refresh flow with an external API. I was wondering if (3 years later, to be fair) you might still have such an example?

    Admittedly I may be way in over my head on this one as I am definitely an engineer (not developer) but figured I’d take a stab at borrowing some other code. Goal is simple. Authenticate to internal service, make API call for json response, spit response back out (and alert if value hits XYZ).

    (Hey @RossPerez / @PeterMattsson - same question if either of you managed to get working code examples.)

    Thanks either way!