401尝试从Windows Live(ColdFusion)获取访问令牌时

时间:2011-05-24 20:17:56

标签: authentication coldfusion oauth

我正在尝试按照微软提供的获取访问令牌的示例: http://msdn.microsoft.com/en-us/library/ff750952.aspx

我的代码如下所示:

<cfset ACCESS_TOKEN_URL = "https://consent.live.com/AccessToken.aspx" />

<cfset clientID = "0000000048052422" />
<cfset secretKey = "9MzM2FgYMHDg2TF9165PaU548ix4efVg" />
<cfset callbackURL = "http://sportsbuzz.local/" />

<cfhttp method="post" url="#ACCESS_TOKEN_URL#" result="liveResult">
    <cfhttpparam type="url" name="wrap_client_id" value="#clientID#" />
    <cfhttpparam type="url" name="wrap_client_secret" value="#secretKey#" />
    <cfhttpparam type="url" name="wrap_callback" value="#callbackURL#" />
    <cfhttpparam type="url" name="wrap_verification_code" value="#url.wrap_verification_code#" />
    <cfhttpparam type="url" name="idtype" value="CID" />
</cfhttp>

<cfdump var="#liveresult#">

但是我收到了401错误以及以下回复:

Filecontent 401 - 未经授权:由于凭据无效,访问被拒绝。

服务器错误

401 - 未经授权:由于凭据无效,访问被拒绝。

您无权使用以下凭据查看此目录或页面你提供了。

标头HTTP / 1.1 401未授权过期:-1日期:2011年5月24日星期二20:11:52 GMT服务器:Microsoft-IIS / 7.5内容长度:1293 Pragma:no-cache Cache-Control:no-cache Set-Cookie :mktstate = S = 948418761&amp; U =&amp; E =&amp; P =&amp; B =;域= .live.com; path = / Set-Cookie:mkt1 = norm =;域= .live.com; path = / Set-Cookie:mkt2 = ui = en-us;域= .consent.live.com; path = / WWW-Authenticate:WRAP X-AspNet-Version:2.0.50727 PPServer:PPV:30 H:BAYIDSTOOL1B09 V:0 Content-Type:text / html

我不明白我哪里出错了。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

您是否首先获得了验证码(大多数OAuth实施中的请求令牌)?

首先要获取访问令牌:http://msdn.microsoft.com/en-us/library/ff749592.aspx

你正在使用一些url.wrap_verification_code变量,但它没有在这段代码中设置。

相关问题