Oauth authentication


#1
$.ajax({ type: 'POST', url: "https://api.twitter.com/oauth/request_token", beforeSend: function (xhr){ xhr.setRequestHeader('Authorization', 'OAuth oauth_nonce="value", oauth_callback="http%3A%2F%2Fmyapp.com%3A3005%2Ftwitter%2Fprocess_callback", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1300228849", oauth_consumer_key="key", oauth_signature="signature", oauth_version="1.0"'); }, data: {include_entities:true}, success: function(data){alert(data)}, dataType: "json",

error:function(edata){
alert(edata);
}
});

I’m trying to get an access token with this method. I get the 403 forbidden status. Am I doing anything wrong?


#2

In most situations, we don’t support or encourage use of the OAuth methods from Javascript. It’s odd that you would pass include_entities=true to the oauth/request_token method which isn’t an API resource that yields entities. The method also doesn’t yield JSON. See [node:204] for more tips on debugging OAuth issues.


#3

将strURL =的 “https://api.twitter.com/1/statuses/update.json?include_entities=true HTTP/1.1”
设置 XMLHTTP = 的CreateObject (“MSXML2.ServerXMLHTTP”的的服务器。)
打开 “POST” ,将strURL,假 XMLHTTP。
XMLHTTP。setRequestHeader “连接”,“关闭”
XMLHTTP。setRequestHeader “用户代理”,“OAuth的宝石v0.4.4”
XMLHTTP。setRequestHeader “内容类型”,“应用程序/ x - www的形式,进行了urlencoded”
XMLHTTP。setRequestHeader “授权”,“OAuth的oauth_consumer_key = oauth_consumer_key”
XMLHTTP。setRequestHeader “授权”,“oauth_nonce = oauth_nonce”
XMLHTTP。setRequestHeader “授权”,“oauth_signature = oauth_signature”
XMLHTTP。setRequestHeader “授权”,“oauth_signature_method = HMAC-SHA1”
XMLHTTP。setRequestHeader “授权”,“oauth_timestamp =” 时间戳()
XMLHTTP。setRequestHeader “授权”,“oauth_token = oauth_token”
XMLHTTP。setRequestHeader “授权”,“oauth_version = 1.0”
XMLHTTP。setRequestHeader “主机”,“api.twitter.com
XMLHTTP。“状态=你好%20Ladies的%20%2B%20Gentlemen%2C%20A%20signed的%20OAuth%20request%21”
postTransaction = XMLHTTP 的responseText
XMLHTTP。中止()
XMLHTTP =没有


#4

$。阿贾克斯({
类型: ‘POST’ ,
网址: “https://api.twitter.com/oauth/request_token”
beforeSend 功能( XHR ){
XHR。setRequestHeader (‘授权’ , 'OAuth的oauth_nonce =“值”,oauth_callback =“HTTP%3A%2F%2Fmyapp.com%3A3005%2Ftwitter%2Fprocess_callback”,oauth_signature_method =“HMAC-SHA1”,oauth_timestamp =“1300228849”, oauth_consumer_key =“键”,oauth_signature =“签名”,oauth_version =“1.0” );
} ,
数据: { include_entities :真正的,
成功: 函数(数据){ 警报(的数据)} ,
“JSON” , 数据类型:

错误:函数(纺织网)
警报( EDATA );
}
} );


#5

oauth_consumer_key xvz1evFS4wEEPTGEFPHBog


#6

oauth_consumer_key xvz1evFS4wEEPTGEFPHBog