有关在特定Google Apps域上实施Google OpenID的问题

时间:2012-09-14 21:22:19

标签: c# asp.net google-apps google-openid

我正在尝试实施Google OpenID登录

我有以下问题:

  1. 我在哪里可以获得行
  2. 中变量openidurl的值

    IAuthenticationRequest request = openid.CreateRequest(openidurl);

    2 ..如何仅限制某个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 OpenID。

0 个答案:

没有答案