2

I'm actually using this js function for the facebook connect.

window.fbAsyncInit = function(){
   FB.init({ 
    appId: '371***********',
     status: true,
      cookie: true,
       xfbml: true ,
       oauth:true,
       channelUrl: '<?php echo base_url(); ?>fb-channel-file.php' //this domain
     });
};
(function() {
   var e = document.createElement('script');
   e.type = 'text/javascript';
   e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
   e.async = true;
   document.getElementById("fb-root").appendChild(e);
}());
// FB LOGIN -->

function FBlogin(){
  FB.getLoginStatus(function(r){
    FB.login(function(response) {
      if(response.authResponse) {
        $.ajax({
          type:'GET',
          url: _config_base_url+'/auth/ajax_login',
          dataType:'json',
          data:{'fb_at':response.authResponse.accessToken},
          beforeSend:function(){
            notify('Loading ...',false,'notify-info');
          },
          error:function(_response){
              notify('An error occurred, please try again later.',false); 

            },
            success:function(json){
              notify_destroy();

              window.location.href= _config_base_url+'/profile';

            }
          });
      } else {}
    },{scope:'email'/*,user_birthday,user_location*/});
  });
}

Now i would like to reproduce the same/quite the same, function for allowing people to connect via Twitter, i just turned that for Google+, but i really can't understand how to turn it up for the Twitter oAuth.

Any idea?

itsme
  • 48,972
  • 96
  • 224
  • 345

1 Answers1

3

Update

Original Answer

  • This answer to JavaScript OAuth sign in with Twitter reads like it's not possible or not the best approach to take due to security.

    Problem with this is that anyone who views your page can also now view your consumer key and secret which must be kept private.

    ...

    Twitter do state that every possible effort must be made to keep these values private to avoid this happening

    Unfortunately, there is currently no way to use oAuth in Browser based JavaScript securely.

  • jsOAuth might be helpful but, as mentioned in the above answer, security is an issue.

    jsOAuth is a javascript library implementing the OAuth protocol. jsOAuth aims to form the basis of custom clients such as Twitter and Yahoo.

    ...

    For security reasons jsOAuth doesn't run in the browser. Browsers are only mentioned here for running the test suite.

Community
  • 1
  • 1
JSuar
  • 21,056
  • 4
  • 39
  • 83