0

I have followed the tutorial in the documentation for Google authentication of a user from my Chrome extension written in React.

Since the tutorial is not for React, I had to adjust the way of calling chrome.identity.getAuthToken. I have put the call to chrome.identity.getAuthToken into useEffect in my App component:

function App() {
    useEffect(
        () => {
            console.log('chrome', chrome)
            console.log('chrome.identity', chrome.identity)
            console.log('chrome.identity.getAuthToken', chrome.identity.getAuthToken)
            // eslint-disable-next-line no-undef
            chrome.identity.getAuthToken({interactive: true}, function(token) {
                console.log('Token:', token);
            });
        },
        []
    )
    return (
        ... // Stuff unrelated to authentication, renders without a problem
    );
}

The output in the console is:

enter image description here

So, the function chrome.identity.getAuthToken is defined, but is not supported. What does "not supported" mean? What could I be missing?

AlwaysLearning
  • 7,257
  • 4
  • 33
  • 68

1 Answers1

0

As per the comment of @wOxxOm, the problem is that chrome.identity.getAuthToken is not supported by Opera.

The workaround for Opera that worked was to use chrome.identity.launchWebAuthFlow.

The linked post provides an example of usage. Make sure to read carefully the comments in that example.

AlwaysLearning
  • 7,257
  • 4
  • 33
  • 68