Facebook UserName WPF [英] Facebook UserName WPF

查看:110
本文介绍了Facebook UserName WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它很简单的问题,我是新来的,我无法理解这个问题,我试图获取用户名并将其显示在一个标签中,当我尝试这个代码来获取访问令牌不要输入条件:
它进入( browser_navigated )的事件,但不是条件,任何人都知道什么是问题?

Its very simple question, I'm new to this and I can't understand the problem , I am trying to get the user name and display it in a label , when i try this code to get the access token it doesn't enter the condition : it enters the event of (browser_navigated) but not the Conditions in , anyone knows whats the problem ?

private void webBrowser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
        FacebookOAuthResult result;

        if (FacebookOAuthResult.TryParse(e.Uri, out result))
        {       
            if (result.IsSuccess)
            {
                var accesstoken = result.AccessToken;
            }
            else
            {
                var errorDescription = result.ErrorDescription;
                var errorReason = result.ErrorReason;
            }
        }


推荐答案

是wpf浏览器控件中一个烦人的错误,忽略#后的所有内容。 (这仅适用于基于wpf的Web浏览器控件,因此它也存在于silverlight和wp7网络浏览器控件中。)

There is an annoying bug in wpf browser control which ignores everything after #. (This is only for web browser controls based on wpf so it is present in silverlight and wp7 web browser controls as well.)

Facebook返回访问令牌作为url片段的一部分。

Facebook returns access token as part of url fragment.

https://url.com#access_token=....

由于错误,当您通过 e.Uri 作为参数时,它不会部分 #access_token = .. so fb c#sdk认为它不是一个有效的oauth回调URL,因此 TryParse 总是返回false

Due to the bug, when you pass e.Uri as a parameter it doesn't part #access_token=.. thus fb c# sdk thinks it is not a valid oauth callback url and thus TryParse always returns false.

解决方案:
使用winforms浏览器控件进行登录或设置 response_type 作为代码令牌,然后交换访问令牌的代码。

Solution: Either use the winforms browser control for login or set response_type as code token and then exchange code for access token.

这篇关于Facebook UserName WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆