Tomas McGuinness
Tomas McGuinness

Reputation: 7691

Does Facebook generate the same "offline_access" Access Token for the same user each time they authenticate?

I'm building a web application and I'm using OAuth to provide Facebook authentication. I've successfully generated an access_token and each time the user logs out/back in, I match their access_token to find their account. This works very well.

In addition, I'm building a Windows Phone 7 companion app. I've got the same process for authentication, using the Facebook SDK, but the access_token that is returned is different. This means I cannot match the account.

Since the logout/login to my web application appears to generate the same access_token repeatedly, I'm confused as to why the mobile app generates a different access token.

Can anyone tell me if the behaviour I'm expecting is correct? I've scoured the Facebook documentation, but can't find anything relevant. Maybe OAuth isn't the correct thing to do here.

Upvotes: 0

Views: 271

Answers (1)

Tomas McGuinness
Tomas McGuinness

Reputation: 7691

Each time I logged in, the code would return a different access_code value. I needed to add a new field called "response_type" with a value of "code". This then redirected me to the login page and responded with the correct token, which I then exchanged for an access code.

To generate the URL, this was the code:

Facebook.FacebookOAuthClient client = new Facebook.FacebookOAuthClient();
client.AppId = "285539721457932";
client.AppSecret = "65233641cf71e6fa9fef5ecd7d802ebf";
client.RedirectUri = new Uri("http://www.imaybelate.com/Account/FacebookCallback");

url = client.GetLoginUrl(new Dictionary<string, object>()
{
    { "display", "wap" },
    { "response_type", "code" },
    { "permissions","offline_access"}
}).ToString();

Upvotes: 1

Related Questions