简体   繁体   English

使用Windows 8而非Windows 7时,Google Api Redirect在WP7上给我404错误

[英]Google Api Redirect gives me 404 error on WP7 When using Windows 8 but not Windows 7

I been scratching my head trying to figure out why a project I have(what I did not touch) was not working anymore. 我挠头想弄清楚为什么我拥有的项目(我没有碰过的项目)不再起作用。

Basically I was trying trying to get some data back from google contacts. 基本上,我试图从Google通讯录中获取一些数据。 When I selected "allow" in the oAuth part it would keep giving me a 404 error. 当我在oAuth部分中选择“允许”时,它将不断显示404错误。 This is all done in the windows phone 7 emulator. 这些都是在Windows Phone 7仿真器中完成的。

I then realized that I was on my Windows 8 partition so I went back to my windows 7 partition and it works. 然后,我意识到自己在Windows 8分区上,因此我回到Windows 7分区上,它可以正常工作。

Wondering if it is some IE 10 issue or something. 想知道这是某些IE 10问题还是什么。 Anyone have any theories of why this is happening? 任何人都有为什么发生这种情况的任何理论?

Edit 编辑

Here is some quick sample code I whipped up maybe someone can try it and tell me what is going on. 这是我快速整理的一些快速示例代码,也许有人可以尝试并告诉我发生了什么。

 string clientId = "You client id here";

        public MainPage()
        {
            InitializeComponent();

            string url = String.Format("https://accounts.google.com/o/oauth2/auth?scope=https://www.google.com/m8/feeds&redirect_uri=http://localhost&response_type=code&approval_prompt=auto&client_id={0}", clientId);
            webBrowser1.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(webBrowser1_Navigated);



            webBrowser1.Navigate(new Uri(url, UriKind.Absolute));




        }



        void webBrowser1_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
           var queryParmas = e.Uri.ParseQueryString();

           foreach (var item in queryParmas)
           {
               if (item.Key == "code")
               {
                   string test1 = "If you got here then it works";
                   string test2 = "in windows 8";

               }
           }
        }


    }

xaml a

 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <phone:WebBrowser HorizontalAlignment="Left" IsScriptEnabled="True" Name="webBrowser1" VerticalAlignment="Top" Height="669" Width="468" />
        </Grid>

Edit2 编辑2

They released IE 10 for Windows 7 so I installed that and it still works on Windows 7 so I guess it is not an IE issue. 他们发布了适用于Windows 7的IE 10,因此我进行了安装,并且仍可在Windows 7上运行,因此我认为这不是IE问题。 Must be something with Windows 8? Windows 8一定是某些东西吗? Maybe iis? 也许是吗?

Edit3 编辑3

Here is a flow of what is happening in Windows 7 这是Windows 7中发生的事情的流程

  1. Application start up and loads MainPg.xmal 应用程序启动并加载MainPg.xmal
  2. Navigated is triggered but if statement is skipped 导航被触发,但是如果语句被跳过
  3. User Sees Google Login Page and enters in information and hits login 用户看到Google登录页面并输入信息并点击登录
  4. Navigated is triggered but if statement is skipped 导航被触发,但是如果语句被跳过
  5. User sees "request page" and must allow application permissions 用户看到“请求页面”,并且必须允许应用程序权限
  6. User hit allow 用户点击允许
  7. Navigated is triggered and goes into "if" statement 导航被触发并进入“ if”语句
  8. User sees IIS 7 screen. 用户看到IIS 7屏幕。

Here is a flow of what is happening in Windows 8 这是Windows 8中发生的事情的流程

  1. Application start up and loads MainPg.xmal 应用程序启动并加载MainPg.xmal
  2. Navigated is triggered but if statement is skipped 导航被触发,但是如果语句被跳过
  3. User Sees Google Login Page and enters in information and hits login 用户看到Google登录页面并输入信息并点击登录
  4. Navigated is triggered but if statement is skipped 导航被触发,但是如果语句被跳过
  5. User sees "request page" and must allow application permissions 用户看到“请求页面”,并且必须允许应用程序权限
  6. User hit allow 用户点击允许
  7. Goes to 404 pages Navigated is not triggered. 转到404页未触发“导航”。

As you can see it goes all wrong after the allow button is pressed. 如您所见,按下“允许”按钮后,一切都会出错。 In windows 7 it goes back to the Navigated method and then shows IIS 7 welcome page but in Windows 8 after the allow button is hit it does not go to the navigated page and shows 404 instead. 在Windows 7中,它返回到“导航”方法,然后显示IIS 7欢迎页面,但是在Windows 8中,单击“允许”按钮后,它没有转到导航页面,而是显示404。

You should be using the "Navigating" event handler, not the "Navigated" event handler. 您应该使用“ Navigating”事件处理程序,而不是“ Navigated”事件处理程序。 This will allow you to cancel the navigation when you get the code value. 这将使您在获得代码值时取消导航。 The navigated handler is called after the navigation and since the callback url does not really exist, it throws the 404 error. 导航后的处理程序在导航后被调用,并且由于回调URL确实不存在,因此会引发404错误。 It seems like it is operating correctly on your Windows 8, not sure why you are not getting the 404 on Windows 7 because you should see it there too. 似乎它在Windows 8上正常运行,不确定为什么在Windows 7上没有安装404,因为您也应该在那里看到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM