I am pretty new to the Facebook API and am using the Javascript SDK to do most of my work. I am logging in with:
FB.getLoginStatus(function (response) {
if (response.status === 'connected') {
document.location.href = '<%: ResolveUrl("~/Account") %>/AuthenticateFacebook?accessToken=' + encodeURI(response.authResponse.accessToken) + '&userID=' + encodeURI(response.authResponse.userID) + '&returnUrl=' + $('#returnUrl').val();
}
}
This is sending the result of the login response to my authenticate page. This is working fine. Later on when I want to use the accessToken on the server is where I am stuck.
I am also trying to use the Facebook C# SDK to do basic stuff. That requires the accessToken so my question is how can I access the from servers side, or do I store that somewhere?
The site is MVC3 with a basic ASP.NET membership service underneath. Any help or guidance on this is really appreciated.
What you have so far is excellent. It is the way that the C# SDK developers want you to do it.
To store it server-side, you can place that into session. Bear in mind that the access token is only good for an hour or so. So occasionally you will want to grab a new token client-side to refresh the one on your server.
You have a few options more than just dropping it into session: