使用存储的访问令牌自动登录

时间:2013-01-04 02:07:18

标签: c# facebook windows-8 facebook-c#-sdk facebook-authentication

在我为Windows 8编写的应用程序中,我通过Facebook进行身份验证。我想这样做,你不必每次都输入你的凭据。我能够写入文件用户的访问令牌,但我无法检查它是否仍然有效。我需要这样的东西 - if (_fb.TryLoginWithStoredToken (storedToken)) {.... }.

如果返回false,则抛出正常的Facebook登录窗口,即:

loginUrl var = _fb.GetLoginUrl (new
                 {
                     client_id = _facebookAppId,
                     redirect_uri = redirectUrl,
                     scope = _permissions,
                     display = "popup"
                     response_type = "token"
                 });
                 endUri var = new Uri (redirectUrl);
                 WebAuthenticationResult await WebAuthenticationBroker.AuthenticateAsync WebAuthenticationResult = (
                                                         WebAuthenticationOptions.None,
                                                         loginUrl,
                                                         endUri);
                 if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
                 {
                     callbackUri var = new Uri (WebAuthenticationResult.ResponseData.ToString ());
                     _fb.ParseOAuthCallbackUrl facebookOAuthResult = var (callbackUri);
                     accessToken var = facebookOAuthResult.AccessToken;

我希望这是可能的,如果没有,也许你有更好的想法如何获得这种效果;)

1 个答案:

答案 0 :(得分:1)

不幸的是,此时Facebook并不支持所需的单点登录redirect_uri,这将允许这种情况发生。因此,这是不可能的。