I am following Google oAuth tutorial. And I am having some trouble with authorizing user.
I am sending user to twitter for authorization. As this is chrome extension and there is no callback. I dont know how to send tweet on the behalf of that user. How I am doing things:
1). I have a background page that has the code of authorizing user from twitter. On the time when user install the extension, background page send that user to twitter for authorization. My authorization method is getting called with their call back. But dont know if I am having everything to make a tweet.
2). Now when user will click on extension icon, the popup.html will be appear. And on this page I want user to send a tweet. How?
Following is my code:
manifest.json
{
“name”: “TweetChrome”,
“version”: “1.0”,
“description”: “Tweet from Chrome”,
“browser_action”: {
“default_icon”: “images/share.png”,
“popup”: “popup.html”
},
“permissions”: [
“tabs”,
“http://ajax.googleapis.com”,
"://.twitter.com/*",
“clipboardWrite”
],
“options_page”: “options.html”,
“background_page”: “background.html”
}
background.html
I am getting some html page markup in resp of callback
method. I dont know what it is for?
var oauth = ChromeExOAuth.initBackgroundPage({
‘request_url’: ‘https://api.twitter.com/oauth/request_token’,
‘authorize_url’: ‘https://api.twitter.com/oauth/authorize’,
‘access_url’: ‘https://api.twitter.com/oauth/access_token’,
‘consumer_key’: ‘key’,
‘consumer_secret’: ‘secret’,
‘scope’: ‘’,
‘app_name’: ‘TweetChrome’
});
oauth.authorize(onAuthorized);
function onAuthorized() {
var url = ‘https://api.twitter.com/oauth/authorize’;
//as they are optional, i left empty
var request = {
‘force_login’: ‘’,
‘screen_name’: ‘’
};
oauth.sendSignedRequest(url, callback, request);
};
function callback(resp, xhr) { alert(‘it get called too’); };
popup.html
To tweet I am using a borrowed twitter.js <https://github.com/abraham/omnitweet/blob/master/extension/javascript/twitter.js>.
I didn't wrote it.
<code>Twitter.verify_credentials({install: true});
Twitter.update("test");
My approach of oauth is right on having it in a background page? As my
authorization is getting call how much far I am to make a tweet for a
user?
Any help will be appreciated. I am hopeful to solve this issue to
finish my extension.