Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 关于在某个Google应用程序域上实现Google OpenID的问题_C#_Asp.net_Google Apps_Google Openid - Fatal编程技术网

C# 关于在某个Google应用程序域上实现Google OpenID的问题

C# 关于在某个Google应用程序域上实现Google OpenID的问题,c#,asp.net,google-apps,google-openid,C#,Asp.net,Google Apps,Google Openid,我正在尝试实现一个Google OpenID登录 我有以下问题: 在哪里可以获得行中变量openidurl的值 IAAuthenticationRequest=openid.CreateRequestopenidurl 二,。。如何仅限制某个Google Apps域的登录 代码如下: protected void Page_Load(object sender, EventArgs e) { OpenIdRelyingParty openid = new Open

我正在尝试实现一个Google OpenID登录

我有以下问题:

在哪里可以获得行中变量openidurl的值 IAAuthenticationRequest=openid.CreateRequestopenidurl

二,。。如何仅限制某个Google Apps域的登录

代码如下:

    protected void Page_Load(object sender, EventArgs e)
    {
        OpenIdRelyingParty openid = new OpenIdRelyingParty();
        var response = openid.GetResponse();
        if (response != null)
        {
            switch (response.Status)
            {
                case AuthenticationStatus.Authenticated:

                    var fetch = response.GetExtension<FetchResponse>();
                    string email = string.Empty;
                    if (fetch != null)
                    {
                        email = fetch.GetAttributeValue(WellKnownAttributes.Contact.Email);
                    }

                    //FormsAuthentication.RedirectFromLoginPage(response.ClaimedIdentifier, false);
                    Session["email"] = email;
                    Response.Redirect("profile.aspx");
                    break;
            }
        }
    }

    protected void OpenLogin_Click(object src, CommandEventArgs e)
    {
        string openidurl = "https://www.google.com/accounts/o8/id?id=initial_id"; //auxiliary initial id. ??????
        //The Request
        using (OpenIdRelyingParty openid = new OpenIdRelyingParty())
        {
            IAuthenticationRequest request = openid.CreateRequest(openidurl);

            var fetch = new FetchRequest();
            fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
            request.AddExtension(fetch);

            // Send your visitor to their Provider for authentication.
            request.RedirectToProvider();
        }
    }
}

提前感谢,这是我第一次使用Google OpenIDs。

签出此链接或此StackOverFlow链接我在编写上面的代码时已经签出了这些链接,我正在使用DotNetOpenAuth。不过谢谢你的回复。。。