I am writing an MVC 3 application and am using Facebook C# SDK. Please check what's wrong with this login:
[Authorize(Roles = "Admin")]
[FacebookAuthorize(
LoginUrl = "https://graph.facebook.com/oauth/authorize?client_id=186437571372857&redirect_uri=http://portugalparty.com/Admin/AIndex/&scope=publish_stream,create_event,email",
开发者_运维问答 Perms = "publish_stream,create_event,email")]
The problem
First, the user enters the site login and then, is asked for the Facebook login and, if necessary, the permissions.
Then, after Facebook login and permissions are set, I watch an unending tennis game between my site and Facebook and it never stops!
What is wrong and what can I do about it?
Here's the stuff in my web.config that are related to this SDK:
I AM NOT WRITING AN Canvas application. I just want to use the Facebook in my MVC application on my domain.
<system.web>
<httpHandlers>
<add verb="*" path="facebookredirect.axd"
type="Facebook.Web.FacebookAppRedirectHttpHandler, Facebook.Web" />
</httpHandlers>
Some info, I remember:
I have seen the user enter the above action once and then I went to do other things. Many things might have happened between that moment and now.
One is that I have changed the site URL in facebook app settings from
"http://portugalparty.com/Admin/Index/"
to"http://portugalparty.com/Admin/AIndex/"
. Facebook said it could take several minutes for the changes to reflect in all servers, but it's already been many hours! Maybe this isn't the problem.
Do you know what is the problem? I can look for more information if you tell me what to look for.
Thanks
EDIT: Cookie details
I did the log on a different page of my site and redirected the URL which action has the FacebookAuthorize attribute, but still the problem persists.
I queried the Facebook cookie on my site (portugalparty.com) and realized this data:
this.Request.Cookies[1]
{System.Web.HttpCookie}
Domain: null
Expires: {01-01-0001 00:00:00}
HasKeys: true
HttpOnly: false
Name: "fbs_186437571372857"
Path: "/"
Secure: false
Value: "\"access_token=234%7C0e147965318dff91499e702d-1270460469%7CKzr7Gp9oY1FOkT...........fsd...fUf14Eb3223457fG6fWMI&base_domain=portugalparty.com&expires=0&secret=313c9.a.sd7861&session_key=0e147965318dff91499e702d-1270460469&sig=702511b1gdfgdfgdfg23tuy587684653252354356ed25c03c989&uid=1270456469\""
Values: {%22access_token=186437571372857%257C0e1gte235318dff91499e702d-1270460469%257C324zr7Gp9oY1FOkTnU14Eb7H6fWMI&base_domain=portugalparty.com&expires=0&secret=fb196116d9dfds32jty6253456645c97861&session_key=0e1479653fsd3245221491499e702d-1270460469&sig=702511b1a35423543534f45657d25c03c989&uid=127675444429%22}
I don't know much about cookies, but why is the Domain name property set to null? In Firefox, I can see the cookie in the folder of my domain in the Cookies window.
And why is the Expires property set to the beginning of time? I asked for the offline access permission, but I guess that has nothing to do with the cookie, right?
Are the details of the cookie OK?
Does it have anything to do with the IIS 7?
I changed my hosts file so that I run the MVC project locally as if I were online. In order to avoid writing the port manually I am running the project through IIS (I choose the option "Use local IIS Web server". Could it be because of this?
Thanks!
I think you are probably missing the Javascript portion of the authentication. When you are developing a connect app the FacebookAuthorize filter only checks to see if the user has the permissions and then sends them to a page on your site that will use the Javascript SDK to prompt the user for permissions. The URL you have set as the LoginUrl is not going to work. That url should be something on your site like /login. Then on the login page you use the Facebook Javascript SDK to actually handle the authentication. See the facebook documentation for more details: http://developers.facebook.com/docs/guides/web/#registration
精彩评论