JavaScript OAuth sign in with Twitter

前端 未结 4 1291
清歌不尽
清歌不尽 2020-12-08 17:35

I have to integrate Sign-in-with Twitter in my app as below. https://dev.twitter.com/docs/auth/sign-twitter It is browser based app developed in JavaScript I have been refe

相关标签:
4条回答
  • 2020-12-08 18:11

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

    Now, someone could write an app that uses your app credentials and do naughty and bad things to the point that twitter and users ban you, and there isnt anything you can do.

    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.

    0 讨论(0)
  • 2020-12-08 18:20

    Check out the Twitter @Anywhere JSDK authComplete and signOut events and callbacks at https://dev.twitter.com/docs/anywhere/welcome#login-signup

    twttr.anywhere(function (T) {
    
        T.bind("authComplete", function (e, user) {
          // triggered when auth completed successfully
        });
    
        T.bind("signOut", function (e) {
          // triggered when user logs out
        });
    
    });
    
    0 讨论(0)
  • 2020-12-08 18:31

    Use below code in consumer.js and select example provider in index.html drop down list

    consumer.example =
    { consumerKey   : "your_app_key"
    , consumerSecret: "your_app_secret"
    , serviceProvider:
      { signatureMethod     : "HMAC-SHA1"
      , requestTokenURL     : "https://twitter.com/oauth/request_token"
      , userAuthorizationURL: "https://twitter.com/oauth/authorize"
      , accessTokenURL      : "https://twitter.com/oauth/access_token"
      , echoURL             : "http://localhost/oauth-provider/echo" 
      }
    };
    
    0 讨论(0)
  • 2020-12-08 18:31

    Since I was searching for the same thing, trying not to use a custom PHP solution, I came across this very simple integration at http://www.fullondesign.co.uk/coding/2516-how-use-twitter-oauth-1-1-javascriptjquery.htm which uses a PHP proxy that accepts whatever twitter api call you'd like to retrieve from your javascript ..

    I'm definitely taking a look at it

    0 讨论(0)
提交回复
热议问题