launchWebAuthFlow: callback URI only opens empty window

959 views
Skip to first unread message

ShadowHunter

unread,
Jun 2, 2015, 5:49:09 PM6/2/15
to chromium-...@chromium.org
Sorry for yet another probably noob question, normally I don't give in until I find a solution myself but this one has me going for 3 days and it is time to admit I'm stuck...

I'm trying to get use PushBullet OAuth 2 for an Chrome extension working:

background.js

var client_id = '<32 DIGIT CLIENT ID>';
var redirectUri = "chrome-extension://lgekckejcpodobwpelekldnhcbenimbe/oauth2";
var auth_url = "https://www.pushbullet.com/authorize?client_id=" + client_id + "&redirect_uri=" + encodeURIComponent(redirectUri) + "&response_type=token";

chrome.identity.launchWebAuthFlow({'url':auth_url,'interactive':true}, function(redirect_url){
console.log(redirect_url)
});

manifest.json:

"permissions": [
    "identity",
    "*://*.google.com/*",
"*://*.pushbullet.com/*",
"storage"
  ],
  "web_accessible_resources": [
"/oauth2/*"

When the extension is loaded PushBullet asked correctly for permission, when approved a blank window (or in my case an empty window less pop-up) opens and the extension is simply waiting... when I close this blank window follwing is appened to the console log:

Unchecked runtime.lastError while running identity.launchWebAuthFlow: The user did not approve access.

When I call the auth_url manually in a browser and approve with PushBullet I do receive the callback uri with a token:
 
Callback URI from PushBullet: chrome-extension://lgekckejcpodobwpelekldnhcbenimbe/oauth2#access_token=o.zrrWrDozxMu6kftrMHb89siYJQhRVcoL

I was expecting that launchWebAuthFlow would take care of all and would show my the redirect URL as coded in the callback function... but it doesn't...

Clearly I'm missing something...

Thanks!

ShadowHunter

ShadowHunter

unread,
Jun 3, 2015, 4:35:42 AM6/3/15
to chromium-...@chromium.org
Solved: http://stackoverflow.com/questions/30612138/chrome-identity-launchwebauthflow-only-opens-empty-callback-page

This is the working code, note the use of getRedirectURL.

background.js

var client_id = 'udHDSpoUZnFc0Q1xMFPdH6uu43rBqcpq';
var redirectUri = chrome.identity.getRedirectURL("oauth2");     
var auth_url = "https://www.pushbullet.com/authorize?client_id=" + client_id + "&redirect_uri=" + redirectUri + "&response_type=token";


    chrome.identity.launchWebAuthFlow({'url':auth_url,'interactive':true}, function(redirect_url){
        console.log(redirect_url)
    });

manifest.js

"permissions": [

    "identity", 
    "*://*.google.com/*",
    "*://*.pushbullet.com/*",   
    "storage"
  ],      

I hope it might help someon else.

With best regards,

ShadowHunter

Reply all
Reply to author
Forward
0 new messages