大家好,我正在尝试使用ColdFusion确定oAuth流程,并且论坛上似乎没有很多信息。
我不断收到“401未经授权-无效的签名-传递的oauth_signature无效”,但我传递的是正确的。
这是我的过程::
我正在使用http://oauth.googlecode.com/svn/code/coldfusion/oauth的oauth代码库
使用Twitter和Google的示例,我将其修改为如下所示。
<cfset sConsumerKey = "XXX">
<cfset sConsumerSecret = "YYY">
<cfset sTokenEndpoint = "http://vimeo.com/oauth/request_token">
<cfset oReqSigMethodSHA = CreateObject("component", "oauth.oauthsignaturemethod_hmac_sha1")>
<cfset oToken = CreateObject("component", "oauth.oauthtoken").createEmptyToken()>
<cfset oConsumer = CreateObject("component", "oauth.oauthconsumer").init(sKey = sConsumerKey, sSecret = sConsumerSecret)>
<cfset myParams = structNew() />
<cfset myParams.oauth_callback = "http://XXX.XXX/web/oAuth/examples_external/vimeo2.cfm" />
<cfset oReq = CreateObject("component", "oauth.oauthrequest").fromConsumerAndToken(
oConsumer = oConsumer,
oToken = oToken,
sHttpMethod = "GET",
sHttpURL = sTokenEndpoint,
stParameters = myParams)>
<cfset oReq.signRequest(
oSignatureMethod = oReqSigMethodSHA,
oConsumer = oConsumer,
oToken = oToken)>
<cfhttp url="#oREQ.getString()#" method="get" result="tokenResponse"/>
然后返回oauth_token和oauth_verifier。
<cfset sConsumerKey = "XXX">
<cfset sConsumerSecret = "YYY">
<cfset sAuthorizationEndpoint = "http://vimeo.com/oauth/access_token"> <!--- Authorize URL --->
<cfset oReqSigMethodSHA = CreateObject("component", "oauth.oauthsignaturemethod_hmac_sha1")>
<cfset oToken = CreateObject("component", "oauth.oauthtoken").createEmptyToken()>
<cfset oConsumer = CreateObject("component", "oauth.oauthconsumer").init(sKey = sConsumerKey, sSecret = sConsumerSecret)>
<cfset myParams = structNew() />
<cfset myParams.oauth_token = URL.oauth_token />
<cfset myParams.oauth_verifier = URL.oauth_verifier />
<cfset myParams.oauth_callback = "oob" />
<cfset oReq = CreateObject("component", "oauth.oauthrequest").fromConsumerAndToken(
oConsumer = oConsumer,
oToken = oToken,
sHttpMethod = "GET",
sHttpURL = sAuthorizationEndpoint ,
stParameters = myParams)>
<cfset oReq.signRequest(
oSignatureMethod = oReqSigMethodSHA,
oConsumer = oConsumer,
oToken = oToken)>
<cfhttp url="#oREQ.getString()#" method="get" result="tokenResponse"/>
<cfdump var="#tokenResponse#" />
并且cfhttp的结果是401错误
最佳答案
在不了解Vimeo API的情况下,在需要POST时尝试通过GET发送数据时,我在oAuth上遇到了同样的问题。
关于coldfusion - Coldfusion Vimeo oAuth,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3242618/