question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use chrome.identity.launchWebAuthFlow to get an OAuth token

See original GitHub issue

https://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:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
sindresorhuscommented, Aug 24, 2016

CLIENT_ID1053844927102-lb8knf98gq6o26bu4v5a3kpqpapj6tkl.apps.googleusercontent.com

0reactions
notlmncommented, Nov 30, 2018

Well, that can just be an optional permission, right?

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found