开发者

Page redirection (on Flickr) issue for WP7 WebBrowser

开发者 https://www.devze.com 2023-04-06 16:19 出处:网络
I am having some difficulties with the OAuth authentication process with Flickr in the WP7 Mango WebBrowser control.

I am having some difficulties with the OAuth authentication process with Flickr in the WP7 Mango WebBrowser control. After for example "Google" sign in the browser gets redirected to the following page:

<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body dir="" onload="document.forms['f'].submit();">
  <form id="f" method="POST" name="f" action="https://open.login.yahoo.com/openid/yrp/return_to?sid=0cbf1840b0b13c261235">
  <input name="openid.ns" value="http://specs.openid.net/auth/2.0" type="hidden">
  <input name="openid.mode" value="id_res" type="hidden">
  <input name="openid.op_endpoint" value="https://www.google.com/accounts/o8/ud" type="hidden">
  <input name="openid.response_nonce" value="2011-09-14T10:16:07Zsdv-LClYH0A" type="hidden">
  <input name="openid.return_to" value="https://open.login.yahoo.com/openid/yrp/return_to?sid=e7578b76a72f0c261235" type="hidden">
  <input name="openid.assoc_handle" value="AOQobUfPBfylWt9AYvILwR347CMGMjh2j4b5jlHe175juowtl05" type="hidden">
  <input name="openid.signed" value="op_endpoint,claimed_id,identity,return_to,response_nonce,assoc_handle,ns.ext1,ns.ext2,ext1.mode,ext1.type.fn,ext1.value.fn,ext1.type.gid,ext1.value.gid,ext1.type.em,ext1.value.em,ext1.type.lg,ext1.value.lg,ext1.type.ln,ext1.value.ln,ext2.auth_time,ext2.auth_policies" type="hidden">
  <input name="openid.sig" value="e5HFSrO0P+yeRJstJHGJlROUkDvVIDGU=" type="hidden">
  <input name="openid.identity" value="https://www.google.com/accounts/o8/id?id=AItOawlmDnO3Bct_YhZlwXpAsU" type="hidden">
  <input name="openid.claimed_id" value="https://www.google.com/accounts/o8/id?id=AItOawnO3Bct_YhZlVBwXpAsU" type="hidden">
  <input name="openid.ns.ext1" value="http://openid.net/srv/ax/1.0" type="hidden">
  <input name="openid.ext1.mode" value="fetch_response" type="hidden">
  <input name="openid.ext1.type.fn" value="http://axschema.org/namePerson/first" type="hidden">
  <input name="openid.ext1.value.fn" value="John" type="hidden">
  <input name="openid.ext1.type.gid" value="http://www.google.com/accounts/api/federated-login/id" type="hidden">
  <input name="openid.ext1.value.gid" value="837487387483142978" type="hidden">
  <input name="openid.ext1.type.em" value="http://axschema.org/contact/email" type="hidden">
  <input name="openid.ext1.value.em" value="john.doe@gmail.com" type="hidden">
  <input name="openid.ext1.type.lg" value="http://axschema.org/pref/language" type="hidden">
  <input name="openid.ext1.value.lg" value="en-US" type="hidden">
  <input name="openid.ext1.type.ln" value="http://axschema.org/namePerson/last" type="hid开发者_StackOverflow中文版den">
  <input name="openid.ext1.value.ln" value="Doe" type="hidden">
  <input name="openid.ns.ext2" value="http://specs.openid.net/extensions/pape/1.0" type="hidden">
  <input name="openid.ext2.auth_time" value="1970-01-01T00:21:55Z" type="hidden">
  <input name="openid.ext2.auth_policies" value="http://schemas.openid.net/pape/policies/2007/06/none" type="hidden">
  <input name="openid.ns.ext3" value="http://specs.openid.net/extensions/ui/1.0" type="hidden">
  <input name="openid.ext3.mode" value="popup" type="hidden">
  <noscript><input value="Continue to open.login.yahoo.com" type="submit"></noscript>
  </form>
</body>
</html>

When the browser has loaded the page i just see the very small button with the text "Continue to open.login.yahoo.com" which in my opinion is not that user friendly. Now you guys might think i didnt test with the IsScriptEnabled="True". With the IsScriptEnabled="True" it just hides the button and shosw a blank page.

I have also tried using the InvokeScript method inorder to run document.forms['f'].submit(), but i just recieve a COM-exception in the application.

Please help! Any tips or suggestions?


I have been pulling my hair with this problem but it seems that there has been made some changes in the WebBrowser control.

I just activate IsScriptEnabled="True" and it seems to trigger the form post. However before that i tried some other methods that seemed to work, one being:

loginBrowser.InvokeScript("eval", "document.forms[0].submit()");

However i came across another problem with one of the last redirects. A GET to the following, i guess it´s where we get the signature and link that we need inorder to authorize the app for our Flickr account (the link below was shortened and is non-functional).

GET /signin/yahoo/?redir=%2Fservices%2Fauth%2F%3Fmobile%3D6%26api_key%3D40d26ecdfghDhr4a1f62219c68d989df%26perms%3Dwrite%26api_sig%3Dcda4de52d6eca8e6db565cf8cd52e1f4&.data=Lnlp......

The solution was the following:

private void loginBrowser_Navigating(object sender, NavigatingEventArgs e)
        {
            if (e.Uri.ToString().Contains("http://www.flickr.com/signin/yahoo/?redir=/services/auth/?mobile=1") && _ishit == false)
            {
                _ishit = true;
                e.Cancel = true;

            }
        }

I hope this helps someone!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号