0
votes

I'm trying to follow this example that microsoft gives for Acquiring an Access Token: http://msdn.microsoft.com/en-us/library/ff750952.aspx

My code looks like this:

<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#">

But I am getting 401 errors with the following response:

Filecontent 401 - Unauthorized: Access is denied due to invalid credentials.

Server Error

401 - Unauthorized: Access is denied due to invalid credentials.

You do not have permission to view this directory or page using the credentials that you supplied.

Header HTTP/1.1 401 Unauthorized Expires: -1 Date: Tue, 24 May 2011 20:11:52 GMT Server: Microsoft-IIS/7.5 Content-Length: 1293 Pragma: no-cache Cache-Control: no-cache Set-Cookie: mktstate=S=948418761&U=&E=&P=&B=; domain=.live.com; path=/ Set-Cookie: mkt1=norm=; domain=.live.com; path=/ Set-Cookie: mkt2=ui=en-us; domain=.consent.live.com; path=/ WWW-Authenticate: WRAP X-AspNet-Version: 2.0.50727 PPServer: PPV: 30 H: BAYIDSTOOL1B09 V: 0 Content-Type: text/html

I don't understand where I am going wrong. Any suggestions?

1

1 Answers

0
votes

Did you get the Verification Code (Request Token in most OAuth implementations) first?

You need to get it first in order to ask for Access Token: http://msdn.microsoft.com/en-us/library/ff749592.aspx

You're using some url.wrap_verification_code variable but it's not being set in this bit of code.