Closed drewharding-da closed 2 years ago
I am encountering the same issue as you but for a different purpose. I'm trying to implement the Google Picker as a standalone script, to be distributed as a library.
My standalone script works for myself as I can authenticate both the outer script and the library script. However, others do not or will not have access to the library script to authenticate. When a user doesn't authenticate the library and runs the script from the outer script (a Google Sheets), then it returns as a ScriptError: Authentication is required.
This oAuth2 library is great, but requires the outer script to be used as a URI (using the library Script ID returns a 403 mismatch error), which doesn't work when people are creating copies of the document in question.
Would love to see this work, as I'm running out of ideas otherwise.
It's not possible for the callback to go directly to the script as described. However, at least for the original case, the recommended approach is to implement an add-on instead of a library.
Add-ons share the same script ID & storage across all documents it's used in. Users would then only need to authenticate once with Jira, regardless of the number of docs/sheets/etc they're interacting with.
As of today when using OAuth2 library within a library, the auth callback must always be directed to the outer script, which can then delegate back to the library as needed. This comment on stack overflow confirms this to be the case. However for me to successfully use this library I need the ability for a state token to be created in a library which is running in an outer script, and then having the redirect URI go straight to the library. The reason this feature is needed for my particular case is due to limitations in the application I am trying to integration to (Jira):
OAuth2.getRedirectUri(scriptId)
function using thescript id
of the library and then setting this back in the service, but when this happens the following error is encountered as part of the callback:The state token is invalid or has expired. Please try again.
because it's not possible in the current implementation for my custom library to receive the callback request.I would appreciate any assistance in having the above feature included for OAuth2 integration.