Foursquare Client?

157 views
Skip to first unread message

Ricardo Peres

unread,
Mar 4, 2012, 5:47:30 AM3/4/12
to dotnet...@googlegroups.com
Hello,

Anyone succeeded in connecting to Foursquare?
I copied the FacebookClient OAuth2 sample and changed URLs according to Foursquare specification, added key and secret to Web.config, but my authorization.AccessToken is always null in the Page_Load method of the page.

Thanks!

RP

Ricardo Peres

unread,
Mar 4, 2012, 11:36:09 AM3/4/12
to dotnet...@googlegroups.com
Heres's a description of my problem:

2 - Registered the return URL as my current project page (http://localhost/...)
3 - Activated log4net logging
4 - When calling client.ProcessUserAuthorization() I get the infamous  Failed to obtain access token. Authorization Server reports reason: (unknown); I saw that Andrew mentioned on StackOverflow that this was due to an out-of-date implementation of the OAuth2 protocol, he was referring to Facebook, but the problem may be the same
5 - On the log file, I get this:

2012-03-04 16:32:32,324 (GMT+0) [6] DEBUG DotNetOpenAuth.Messaging.Channel - Preparing to send AccessTokenAuthorizationCodeRequest (2.0) message.
2012-03-04 16:32:32,324 (GMT+0) [6] INFO  DotNetOpenAuth.Messaging.Channel - Prepared outgoing AccessTokenAuthorizationCodeRequest (2.0) message for https://foursquare.com/oauth2/access_token: 
	code: ____removed____
	redirect_uri: http://localhost:59721/Foursquare.aspx
	grant_type: authorization_code
	client_id: ___removed___
	client_secret: ___removed___
 
2012-03-04 16:32:32,324 (GMT+0) [6] DEBUG DotNetOpenAuth.Messaging.Channel - Sending AccessTokenAuthorizationCodeRequest request.
2012-03-04 16:32:36,604 (GMT+0) [6] DEBUG DotNetOpenAuth.Http - HTTP POST https://foursquare.com/oauth2/access_token
2012-03-04 16:32:37,058 (GMT+0) [6] DEBUG DotNetOpenAuth.Messaging - The following required parameters were missing from the DotNetOpenAuth.OAuth2.Messages.AccessTokenSuccessResponse message: {token_type,
}
2012-03-04 16:32:37,058 (GMT+0) [6] DEBUG DotNetOpenAuth.Messaging - The following required parameters were missing from the DotNetOpenAuth.OAuth2.Messages.AccessTokenFailedResponse message: {error,
}
2012-03-04 16:32:37,073 (GMT+0) [6] DEBUG DotNetOpenAuth.Messaging.Channel - Received UnauthorizedResponse response.
2012-03-04 16:32:37,073 (GMT+0) [6] INFO  DotNetOpenAuth.Messaging.Channel - Processing incoming UnauthorizedResponse (2.0) message:
	realm: Service
	access_token: ___removed___
 
2012-03-04 16:32:37,089 (GMT+0) [6] DEBUG DotNetOpenAuth.Messaging.Channel - After binding element processing, the received UnauthorizedResponse (2.0) message is: 
	realm: Service
	access_token: ___removed___
 
2012-03-04 16:32:37,089 (GMT+0) [6] ERROR DotNetOpenAuth.Messaging - Protocol error: Failed to obtain access token.  Authorization Server reports reason: (unknown)
   at DotNetOpenAuth.Messaging.ErrorUtilities.VerifyProtocol(Boolean condition, String message, Object[] args)
   at DotNetOpenAuth.Messaging.ErrorUtilities.ThrowProtocol(String message, Object[] args)
   at DotNetOpenAuth.OAuth2.ClientBase.UpdateAuthorizationWithResponse(IAuthorizationState authorizationState, EndUserAuthorizationSuccessAuthCodeResponse authorizationSuccess)
   at DotNetOpenAuth.OAuth2.WebServerClient.ProcessUserAuthorization(HttpRequestInfo request)
   at OAuthClient.Foursquare.Page_Load(Object sender, EventArgs e)
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP.foursquare_aspx.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
   at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error)
   at System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
   at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
   at System.Web.HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
   at System.Web.HttpRuntime.ProcessRequest(HttpWorkerRequest wr)
   at Microsoft.VisualStudio.WebHost.Request.Process()
   at Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Connection conn)

6 - The received access_token works fine, I tried it, however, there's something in the response that is causing it to throw an exception

Any ideas? I would be most grateful!

Thanks,

RP

Andrew Arnott

unread,
Mar 4, 2012, 5:45:24 PM3/4/12
to dotnet...@googlegroups.com
Yes, the problem is that Foursquare's OAuth 2 authorization server is not complying with recent OAuth 2 spec drafts, as you guessed.  

You can download a version of DNOA that should be compatible with Foursquare with this Nuget command:
Install-Package DotNetOpenAuth -Version 3.5.0.12037-refresh3 -Pre 
--
You received this message because you are subscribed to the Google Groups "DotNetOpenAuth" group.
To view this discussion on the web visit https://groups.google.com/d/msg/dotnetopenid/-/yunv2Qa3iJMJ.
To post to this group, send email to dotnet...@googlegroups.com.
To unsubscribe from this group, send email to dotnetopenid...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dotnetopenid?hl=en.


--
--
Andrew Arnott
"I [may] not agree with what you have to say, but I'll defend to the death your right to say it." - S. G. Tallentyre

Ricardo Peres

unread,
Mar 5, 2012, 4:03:42 AM3/5/12
to dotnet...@googlegroups.com
Hello again, Andrew!

Thanks a lot, that version did fix the problems with Foursquare and Facebook!
Please be patient with me, I'm new to this OAuth stuff... I won't flood the mailing list, I promise! ;-)

Regards,

RP
To unsubscribe from this group, send email to dotnetopenid+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/dotnetopenid?hl=en.
Reply all
Reply to author
Forward
0 new messages