facebook-csharp-sdk / facebook-winclient-sdk

Facebook SDK for Windows & Windows Phone
http://facebooksdk.net
Apache License 2.0
61 stars 139 forks source link

Invalid Facebook ID cached when renewing access token #22

Closed f2bo closed 9 years ago

f2bo commented 11 years ago

In the LoginAsync method of the FacebookSessionClient, whenever a cached access token expires, it's renewed by prompting with the OAuth dialog again. If the user changes the identity used to log in, the new session is cached, but the Facebook ID is never requested again, so the session data contains an access token for the new user but the Facebook ID corresponds to the previous user.

...
// Prompt OAuth dialog if force renew is true or
// if new permissions are requested or 
// if the access token is expired.
if (force || newPermissions || session.Expires <= DateTime.UtcNow)
{
    var authResult = await PromptOAuthDialog(permissions, WebAuthenticationOptions.None);
    if (authResult != null)
    {
        // THIS IS REUSING THE PREVIOUS SESSION OBJECT WITH A STALE ID
        session.AccessToken = authResult.AccessToken;
        session.Expires = authResult.Expires;
    }
}
...
cwhsu1984 commented 11 years ago

My god... 5 months already and it hasn't been fixed... This is just the issue I saw on Windows phone 8 today, and according to Facebook custom webview should not be used from now on!!

sanjeevdwivedi commented 9 years ago

This issue has been fixed with the refactoring of the SDK.