Skip to content

Instantly share code, notes, and snippets.

@rsanchez1
Created April 18, 2012 15:56
Show Gist options
  • Save rsanchez1/2414502 to your computer and use it in GitHub Desktop.
Save rsanchez1/2414502 to your computer and use it in GitHub Desktop.
tab creation for authentication in touchfeeds
authorizeClick: function() {
var url = "https://accounts.google.com/o/oauth2/auth?client_id=663702953261.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=http://www.google.com/reader/api/0&response_type=code";
chrome.tabs.create({url: url}, function(tab) {this.tabId = tab.id; globalTab = tab;}.bind(this));
this.interval = window.setInterval(this.checkOAuthTitle.bind(this), 1000);
},
checkOAuthTitle: function() {
chrome.tabs.get(this.tabId, function(tabInfo) {
var match = tabInfo.title.split("=");
if (match.length == 2) {
this.code = match[1];
window.clearInterval(this.interval);
chrome.tabs.remove(this.tabId, function() {});
this.tabId = 0;
this.getAccessToken();
}
}.bind(this));
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment