I have some code that is using the google api to show a share dialog on the screen. (this one: https://developers.google.com/drive/api/v3/share-button)
share_client = new gapi.drive.share.ShareClient()
share_client.showSettingsDialog()
But after calling showSettingsDialog, it fails with a 403. I can see the request in my network tab:

I know why it fails and I believe that if only I could add an extra parameter to this request, I could fix this issue. The problem is I can't use something like a Service Worker to intercept and change the request, because this request is actually initiated from a script from apis.google.com, and not from my page's location, so I don't have access to it with a Service Worker. It's also very hard, if at all possible, to modify this api code to make the request that I want. I have tried, a lot.
And if I inspect that share_client object, I can see the point where it goes away from the code that I have control over, to an external resource. It's because the function being called has this [[FunctionLocation]], which points to: https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi. ... /cb=gapi.loaded_2. If I step in the debugger I can see it jumping from this function call, to my local copy of the API, to external scripts hosted in apis.google.com
So my question is how exactly does this work? How can a function point to an external script? Where does this [[FunctionLocation]] comes from? How is it generated? Is it possible to change it? How can it reach this external code without actually making an http request?
Basically I'm asking for any insight on how this all fits together. I'm not so confident that it is actually possible add a parameter to that request like I wanted to, but at this point I'm mostly just curious to learn more about it.
