使用OAuth和javascript的应用程序 [英] application that uses OAuth and javascript
本文介绍了使用OAuth和javascript的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我打算创建一个使用JavaScript的应用,它需要使用OAuth来验证网站的用户身份。
有人能帮帮我吗?任何示例代码?我知道Google Code Javascript OAuth库,但我不知道如何实现..
I am planning to create an app that uses JavaScript and it needs to use OAuth to authenticate user for a website. Can anyone help me out please? Any sample code? I know about the Google Code Javascript OAuth library but I am not sure how to implement that..
推荐答案
有一个JS客户端这里实施OAuth:
http://oauth.googlecode.com/svn/code / javascript /
There is a JS client implementation for OAuth here: http://oauth.googlecode.com/svn/code/javascript/
它包含让您运行的示例代码。基本上,你做的是:
It contains example code to get you running. Basically, what you do is this:
var url = "...";
var accessor = {
token: "...",
tokenSecret: "...",
consumerKey : "...",
consumerSecret: "..."
};
var message = {
action: url,
method: "GET",
parameters: {...}
};
OAuth.completeRequest(message, accessor);
OAuth.SignatureMethod.sign(message, accessor);
url = url + '?' + OAuth.formEncode(message.parameters);
// send request to 'url'
...
干杯,
马蒂亚斯
Cheers, Matthias
这篇关于使用OAuth和javascript的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文