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:
So, the function chrome.identity.getAuthToken
is defined, but is not supported. What does "not supported" mean? What could I be missing?