Closed smdion closed 3 months ago
This Actual API wrapper accepts the authentication token using headers, not query parameters. The library ImportJson doesn't support sending headers, but that can be solved as follows.
Create a function in your ImportJSON.gs
script:
function ImportJSONFromActual(url, query, parseOptions) {
var options = new Object();
options["header"] = {"x-api-key": "<your-api-key>"};
return ImportJSONAdvanced(url, options, query, parseOptions, includeXPath_, defaultTransform_);
}
And call it =ImportJSONFromActual("http://localhost:5007/v1/budgets/<account>/accounts/")
.
Or you can get more creative and create something like ImportJSONWithHeaders, adding a headers parameter so that you can specify any header from the google sheet.
Let us know how it goes.
See this related issue mentioning an alternative project: https://github.com/bradjasper/ImportJSON/issues/235
Thanks! @jhonderson I'll play around with this. Feel free to close!
This may be a user issue and if so, close with zero prejudice.
I am looking at converting from YNAB, but I use the IMPORTJSON functionality in google sheets (via https://github.com/bradjasper/ImportJSON) to pull in transactional data for additional net worth tracking and Year over Year comparison of budgets.
In a google sheets cell I would put in :
=ImportJson("https://api.youneedabudget.com/v1/budgets/<account>/accounts/?access_token=<apikey>")
Using the same thing, but for the Actual API I get forbidden or even going direct to the URL in a browser.
=ImportJson("http://localhost:5007/v1/budgets/<account>/accounts/?access_token=<apikey>")
You are using OAS 3.1, which supports Bearer auth. Is this something that I am doing wrong or is bearer auth not supported. If not supported, do you know another way to pass auth thru a URL or do you have the ability to add bearer auth? (https://swagger.io/docs/specification/authentication/bearer-authentication/)
I also understand this is a passion project and if its not something you want to add/support just say so and close.
Thanks!