gpt4 book ai didi

Coldfusion Vimeo oAuth

转载 作者:行者123 更新时间:2023-12-01 07:59:41 25 4
gpt4 key购买 nike

我正在尝试使用 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 Vimeo oAuth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3242618/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com