0

I thought I had things rolling but I've discovered I have this error after calling getAuthToken with interactive:false :

OAuth2 request failed: Service responded with error: 'Bad Request'

'Bad Request' really tells me very little. Ok, I understand I'll probably need to use interative:true (why?) and so when I attempt that, it spawns my browser, prompts my google login (which I enter and which is a real pain because we have 2-step authentication), then does... nothing... the callback is never called...

Anyone interested in helping me out will probably want to see bits from my manifest.json:

"key": "MII...QAB",
"oauth2": {
    "client_id": "35...-lnf...1pd.apps.googleusercontent.com",
    "scopes": [ "identity" ]
},
"permissions":[ "identity", "https://accounts.google.com/*", "https://www.googleapis.com/*", "https://*.amazonaws.com/*", "<all_urls>" ],

You'll also probably want to see the code in question:

chrome.identity.getAuthToken({ 'interactive': true, 'scopes':['identity'] }, function ( token ) {
    if ( chrome.runtime.lastError ) {
        next(chrome.runtime.lastError);
    } else {
        next( null, token );
    }
});

or, alternatively:

chrome.identity.getAuthToken({ 'interactive': false }, function ( token ) {
    if ( chrome.runtime.lastError ) {
        next(chrome.runtime.lastError);
    } else {
        next( null, token );
    }
});

I am happy to provide any other information that might be helpful in identifying where I'm going wrong.

Reinsbrain
  • 2,235
  • 2
  • 23
  • 35
  • It's meant to be used with the browser's already signed in chrome session (the one signed in on chrome://settings) and if you're already signed in there, it will allow single-click authorization. – kzahel Aug 08 '16 at 13:34
  • @kzahel : yes, i understand that part. it does prompt me to sign in (although I'm already signed in)... then it does nothing and the callback (with token) is never called unless i set interactive:false ... then it tells me "Bad Request" (not enough information to go on...) – Reinsbrain Aug 08 '16 at 19:54

1 Answers1

0

It is stated in the Chrome documentation the purpose/meaning of boolean value in the interactive object, Fetching a token may require the user to sign-in to Chrome, or approve the application's requested scopes. If the interactive flag is true, getAuthToken will prompt the user as necessary. When the flag is false or omitted, getAuthToken will return failure any time a prompt would be required.

Now for your error OAuth2 request failed: Service responded with error: 'Bad Request'

Make sure you provide the Email Address and Product Name in the Consent screen in creating OAuth credentials.

For more information, check this thread.

KENdi
  • 7,576
  • 2
  • 16
  • 31