I am currently developing a chrome extension, and it requires OAuth 2.0 authentication. I am writing the extension (NOT an app) in JavaScript and my code for authentication looks like this:
gapi.client.setApiKey('AIzaSyDUDozQF2xXJd7nybrEhVYgWUsSA4BREWw');
gapi.client.load('youtube', 'v3', function(){
console.log("LOADED");
gapi.auth.authorize({
client_id: "323168009404-njonv6p9tt1d61pa9r2lnpaj18vf1n76.apps.googleusercontent.com",
immediate: false,
scope: "https://www.googleapis.com/auth/youtube.force-ssl"
}, function(){
console.log("AUTHORIZED");
for(var k = 0; k < booksID.length; k++){
addToPlaylist(booksID[k], undefined, undefined);
}
console.log("FINISHED");
var request = gapi.client.youtube.playlists.list({
part: 'snippet',
resource: {
forUsername: 'username'
}
});
});
});
It prints out the "LOADED" statement to the console, but once it reaches the gapi.auth.authorize call, it never executes the callback function, signalling that authentication failed, while at the same time, in the supposed authentication window, I get this error:
I've tried searching the error on google and I can't seem to find a solution. The only solutions that come close are when the origin value in the authentication error report is some sort of IP address. Any help would be greatly appreciated.
By the way, I am trying to access the Youtube Data API.