使用 Twitter 登录 JavaScript OAuth
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2470694/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JavaScript OAuth sign in with Twitter
提问by user296601
I have to integrate Sign-in-with Twitter in my app as below. https://dev.twitter.com/docs/auth/sign-twitterIt is browser based app developed in JavaScript I have been refering google code java script OAuth, but im confused how to use oauth/authenticate and how to get the oauth_token
我必须将登录与 Twitter 集成到我的应用程序中,如下所示。 https://dev.twitter.com/docs/auth/sign-twitter它是用 JavaScript 开发的基于浏览器的应用程序我一直在引用谷歌代码 java 脚本 OAuth,但我很困惑如何使用 oauth/authenticate 以及如何获取 oauth_token
Can any one please help me out with some samples ?
有人可以帮我提供一些样品吗?
回答by Dan
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 和用户禁止您,而您无能为力。
Twitter do state that every possible effort mustbe made to keep these values private to avoid this happening
Twitter的做状态一切可能的努力,必须进行以保持这些价值的私人避免这种情况的发生
Unfortunately, there is currently no way to use oAuth in Browser based JavaScript securely.
不幸的是,目前没有办法在基于浏览器的 JavaScript 中安全地使用 oAuth。
回答by potench
Check out the Twitter @Anywhere JSDK authCompleteand signOutevents and callbacks at https://dev.twitter.com/docs/anywhere/welcome#login-signup
在https://dev.twitter.com/docs/anywhere/welcome#login-signup查看 Twitter @Anywhere JSDKauthComplete和signOut事件和回调
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
});
});
回答by Swar
Use below code in consumer.js and select example provider in index.html drop down list
在consumer.js 中使用以下代码并在index.html 下拉列表中选择示例提供程序
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"
}
};
回答by elQueFaltaba
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.htmwhich uses a PHP proxy that accepts whatever twitter api call you'd like to retrieve from your javascript ..
由于我正在寻找相同的东西,尽量不使用自定义 PHP 解决方案,我在http://www.fullondesign.co.uk/coding/2516-how-use-twitter-oauth- 上遇到了这个非常简单的集成1-1-javascriptjquery.htm使用 PHP 代理,该代理接受您想从 javascript 中检索的任何 twitter api 调用。
I'm definitely taking a look at it
我肯定在看

