2011-09-20 55 views
0

我在WP7 Mango WebBrowser控件中使用Flickr进行OAuth身份验证过程遇到一些困难。 后在浏览器中,例如“谷歌”的标志被重定向到以下页面:页面重定向(在Flickr上)WP7 WebBrowser问题

<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="[email protected]" 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="hidden"> 
    <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> 

当浏览器加载页面我刚看到的文字非常小按钮“继续open.login.yahoo .com“,在我看来,这不是用户友好的。 现在你们可能会认为我没有使用IsScriptEnabled =“True”进行测试。使用IsScriptEnabled =“True”,它只是隐藏按钮并放置一个空白页面。

我也尝试使用InvokeScript方法来运行document.forms ['f']。submit(),但我只是在应用程序中接收COM异常。

请帮忙!任何提示或建议?

回答

1

我一直在拉我的头发与这个问题,但似乎已经做了一些WebBrowser控件的更改。

我只是激活IsScriptEnabled =“True”,它似乎触发表单发布。但是在这之前我试过,似乎工作,其中之一是一些其他的方法:

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

但是我遇到了另一个问题,最后重定向之一。对于下面的GET,我猜这是我们得到我们需要的签名和链接,以便为我们的Flickr帐户授权应用程序(下面的链接被缩短并且不起作用)。

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

的解决方案是以下几点:

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; 

      } 
     } 

我希望这可以帮助别人!