editor4
editor4 copied to clipboard
Pull Data from an API secured with OAUTH
Hi,
how can we pull data from an API protected by OAUTH. is it possible to provide a textbox for a token in the editor UI or have an intercepting function which can get a token and add it to the Authorization header of every request.
My Use case: We have an application (with main, admin modules) where users should have the capability to create their own chart in the admin module. They would leverage the App's APIs to get the data. These APIs are protected by OAUTH. Once a report is finalized, json is saved , which will then be used to render the chart in the main module.
Question 1:Wanted to know how add an authorization header in editor UI or configure it somewhere. Question 2: Do we have a capability to export a json and use it again to render.
Thanks in Advance.
Hi,
There's no support for loading data from protected end points in the Editor. I think the approach for these cases would be to load the data in your main module and then pass it into Editor where the chart can be built around it. You can pass the data via the presetData
config setting.
Here's an example: https://github.com/amcharts/editor4/blob/b927e8d58b10c3c527264456a69710fc497f350f/samples/javascript/am4editor-js-sample/app.js#L648
Hope this helps.
And regarding the second question: yes, the main purpose of the Editor is to generate the chart's JSON config that you can then use as-is to render the chart elsewhere.