2

我一直在研究 DotNetOpenAuth 以使用 Google 应用程序进行身份验证并要求返回电子邮件地址。

当我使用以前版本的 DotNetOpenAuth.dll 时,我有一个工作程序。但是当我用当前版本更新 Dll 时,我的代码就坏了。该应用程序能够进行身份验证,但不回复电子邮件地址。

我的代码是:

<rp:OpenIdButton runat="server" ImageUrl="~/images/google.jpg" Text="Login with Google" ID="OpenIdButton1"
            Identifier="https://www.google.com/accounts/o8/id" LogOnMode="None" OnLoggingIn="test" OnLoggedIn="OpenIdLogin1_LoggedIn">
            <Extensions>
                <sreg:ClaimsRequest Email="Require" />
            </Extensions>

protected void OpenIdLogin1_LoggedIn(object sender, OpenIdEventArgs e)
    {
        // Hide login button.
        OpenIdButton1.Visible = false;        

        // Get email.
        //ClaimsResponse profile = e.Response.GetExtension<ClaimsResponse>();
        ClaimsResponse profile = e.Response.GetUntrustedExtension<ClaimsResponse>();
        string email = profile.Email;  

And the code breaks at the above line.

新的 Dll 有什么变化吗?

4

1 回答 1

0

您的代码依赖于AXFetchAsSregTransform 行为的使用。请查看链接并确保您的 web.config 文件在该<configSections>区域中更新以适应最新 DotNetOpenAuth 所需的新 xml。您的 web.config 可能已经声明了 AXFetchAsSregTransform,但在您更新 configSections 之前它会被忽略。

顺便说一句,您not通常应该使用GetUntrustedExtension.

于 2012-08-23T14:15:34.023 回答