Use chrome.identity.launchWebAuthFlow to get an OAuth token
See original GitHub issuehttps://developer.chrome.com/apps/identity#method-launchWebAuthFlow
var CALLBACK_URL = 'https://'+chrome.runtime.id+'.chromiumapp.org';
var AUTH_URL = 'https://github.com/login/oauth/authorize/?client_id='+CLIENT_ID+'&redirect_uri='+CALLBACK_URL+'&scope=notifications';
...
// Opens a window to initiate GitHub OAuth, fires callback
// with token in the URL.
chrome.identity.launchWebAuthFlow({
url: AUTH_URL,
interactive: true,
}, function(redirectURL) {
var q = redirectURL.substr(redirectURL.indexOf('#')+1);
var parts = q.split('&');
for (var i = 0; i < parts.length; i++) {
var kv = parts[i].split('=');
if (kv[0] == 'access_token') {
token = kv[1];
console.log('token is', token);
}
}
});
This would remove the need for users to generate a personal access token and copy/paste it in themselves.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:16 (10 by maintainers)
Top Results From Across the Web
identity.launchWebAuthFlow - Mozilla - MDN Web Docs
The URL offered by the OAuth2 service provider to get an access token. The details of this URL should be given in the...
Read more >Can chrome.identity.launchWebAuthFlow be used to ...
Yes, in 2019 it still works. Finally got it working... manifest.json { "name": "Extension Name", "description": "Description", ...
Read more >chrome.identity - Chrome Developers
Use the chrome.identity API to get OAuth2 access tokens. ... launchWebAuthFlow hides its web view until the first navigation either redirects to the...
Read more >Failed OAuth2 with Google, via launchWebAuthFlow
identity.getAuthToken flow because it is based on the account that's currently logged in in the Chrome browser(which requires periodical re-logins for accounts ...
Read more >How I Handle Authentication in My Chrome Extension
Visit http://brilliant.org/CodinginFlow/ to get started learning ... auth between Chrome extension and website 14:10 - Access Token vs ID ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
CLIENT_ID
→1053844927102-lb8knf98gq6o26bu4v5a3kpqpapj6tkl.apps.googleusercontent.com
I already did that, the code is almost complete and is at https://github.com/notlmn/notifier-for-github/tree/identity-flow.
I closed it because it was making the extension more complex by adding more code to an otherwise simple extension.
And the other reason being adding additional permissions, which were recently removed in #161, and people were getting concerned about it.