Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. signin: function(){
  2. ChromeUtils.connecttotwitter().then(alert("Step After Then"));
  3. AppDispatcher.dispatch({actionType:TweetSmartActions.SIGN_IN,signedInTwitterUserId: response.user_id});
  4. },
  5.  
  6. var ChromeUtils = {
  7.  
  8. connecttotwitter: function () {
  9.  
  10. return new Promise(function(fulfill,reject){
  11. var request = {
  12. type : "background.twitterRequestToken",
  13. };
  14. alert("Before sendMessage");
  15. chrome.runtime.sendMessage(request, function(response) {
  16.  
  17. if (response)
  18. {
  19. fulfill(response);
  20. }
  21. else
  22. {
  23. reject(response);
  24. }
  25. });
  26. });
  27. },
  28.  
  29. chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
  30.  
  31. console.log("background.js: " + JSON.stringify(request));
  32.  
  33. var type = request.type;
  34.  
  35.  
  36. if (type == "background.twitterRequestToken")
  37. {
  38. oauth.authorize(function(token,secret,userId,screenname){
  39. sendResponse({success:true,userId:userId,screenName:screenname});
  40. });
  41. alert("Alerting before returning true");
  42. return true;
  43. }
  44.  
  45. ChromeExOAuth.prototype.initOAuthFlow = function(callback) {
  46. if (!this.hasToken()) {
  47. var params = ChromeExOAuth.getQueryStringParams();
  48. if (params['chromeexoauthcallback'] == 'true') {
  49. var oauth_token = params['oauth_token'];
  50. var oauth_verifier = params['oauth_verifier']
  51. this.getAccessToken(oauth_token, oauth_verifier, callback);
  52. } else {
  53. var request_params = {
  54. 'url_callback_param' : 'chromeexoauthcallback'
  55. }
  56. this.getRequestToken(function(url) {
  57. alert("Url after get request token " + url);
  58. window.location.href = url;
  59. alert(window.location.href);
  60. }, request_params);
  61. }
  62.  
  63. chrome-extension://kiekipigbdldhggmlohbnhofnjhcbmem/chrome_ex_oauth.html
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement