sorry yet noob question, don't give in until find solution myself 1 has me going 3 days , time admit i'm stuck...
i'm trying authenicate chrome extension use pushbullet user data via oauth2:
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 load extension:
- the pushbullet authorization pop-up opens , asks give permission extension (ok)
- i agree (ok)
- the pushbullet window closes and new empty page opes url of windows callback uri token:
chrome-extension://lgekckejcpodobwpelekldnhcbenimbe/oauth2#access_token=o.zrrwrdozxmu6kftrmhb89siyjqhrvcol
i did not expect empty page open rather having launchwebauthflow captured uri , have written in console log coded in callback function... seems waiting...
the option close empty page see following logged:
unchecked runtime.lasterror while running identity.launchwebauthflow: user did not approve access.
clearly i'm missing vital... need additional code "somewhere" callback uri in background.js?
thanks, appriciate help.
shadowhunter
you misunderstanding identity api.
you cannot use custom callback url. api expects use url of form
https://<app-id>.chromiumapp.org/* which can obtain call chrome.identity.getredirecturl(path)
when provider redirects url matching pattern
https://<app-id>.chromiumapp.org/*, window close, , final redirect url passed callback function.
this because lot of oauth providers not accept chrome-extension:// url valid.
if - great, you'll need use own oauth library (and token storage, worse). chrome.identity works above.
do note network request not sent chromiumapp.org address in flow - it's "virtual" address intercepted api.
Comments
Post a Comment