【发布时间】:2011-03-15 15:09:20
【问题描述】:
我正在尝试使用coldfusion来弄清楚oAuth过程,论坛上似乎没有很多信息。
我不断收到“401 Unauthorized - Invalid signature - The oauth_signature pass was not valid” 但我传递的是正确的。
这是我的过程。::
我正在使用来自 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 错误
【问题讨论】:
-
他们的回复应该更详细,比如
401 Unauthorized - Invalid API Key - The API key passed was not valid。你能看到扩展部分出现在通用代码之后吗? -
是的,有“401 Unauthorized - Invalid signature - The oauth_signature pass was not valid” 但我使用的是 oauth 类,所以它应该是正确的......
-
有没有人对可能的问题有更多反馈?
-
有没有在这方面取得任何进展?我将在下周左右使用 Vimeo 的 API。
标签: coldfusion oauth vimeo http-status-code-401