Thursday, 12 October 2023

How to access Google Drive API from chrome extension running on non-Chrome browsers

I have made a Chrome extension that successfully accesses the Google Drive API. It does so by employing access tokens like so...

chrome.identity.getAuthToken({ interactive: true }, (accessToken) => {
    sendResponse({ type: MESSAGE_PROTOCOL.AUTH_RESPONSE, accessToken });

...however, when I try and run the code on other Chrome-based browsers like Edge it appears that chrome.identity.getAuthToken is not available. After much Googling it seems that there is an alternative (involving launchWebAuthFlow) but I can not find a complete worked example, only little snippets and clues which I am not expert enough to convert into a solution. Surely there must be a complete example somewhere.

A worked example for a different Google API would probably do be fine too.

EDIT: I just found this question which is probably pretty close to what I am after though so far I have failed to get any of the answers to work. I notice that the top voted answer to that question was for manifest v2 and I'm not sure whether the answer will be valid for v3. Can anyone confirm?

EDIT: Just to be clear, I don't have my own server, I want the whole process to be handled by the extension itself.

EDIT: If anyone knows of an existing extension that accesses a Google API, can work on Edge, uses manifest v3, is not compressed/obfuscated and does not rely on its own server then I could examine the code myself and that should do the trick.



from How to access Google Drive API from chrome extension running on non-Chrome browsers

No comments:

Post a Comment