I frequently get “Bad or expired Token” even when the code worked moments ago. I am working in Excel. Usually when this happens, it seems to affect other cells as well.
Short of closing and re-opening Excel, is there anything I can do to re-establish the add-in connection?
There may be many causes for this – momentary network disconnects or abandoning a query before it completes (revising it while the initial query is still processing) are common causes.
Excel has a reload option built into the task pane that should get you reconnected without closing and re-opening the application.
To use this option, click in an empty spot on the task pane, then use the menu indicator at the top-right corner of the task pane and select the Reload option (see the red circle in the image below).
After refreshing the task pane, go to the cell(s) where the =XBRL.showData() formula is used and add an asterisk before the equals sign, press enter, then remove the asterisk to re-initiate the query. You should be able to use Excel’s find and replace for this step if there are many queries.
Consider building query URLs in one cell, and calling them with XBRL.showData from another cell ( =XBRL.showData(A1, “”, “”, “1”) – this lets you manage the query independent of its execution.
Using the XBRL API with the Public Filings Database
Unless otherwise agreed to in writing, any and all use of the XBRL API to authenticate and retrieve data from the XBRL US Database of Public Filings implies user consent and agreement with the XBRL US API Agreement. If you are unable to agree to these terms, do not use the XBRL API.
To use the XBRL API outside of Google Sheets, your account needs to be provisioned for OAuth2 access.
The national consortium for the business reporting standard
XBRL US is a not-for-profit organization supporting the implementation of digital business reporting standards through the development of taxonomies for use by U.S. public and private sectors, with a goal of interoperability between sectors, and by promoting XBRL adoption through marketplace collaboration.