OpenID: попытка получить адрес электронной почты от Google OP

Используйте org.mortbay.jetty.handler. ContextHandler. Вам не нужны дополнительные компоненты как StaticServlet.

В причале домой,

контексты CD $

CP $ javadoc.xml static.xml

$ vi static.xml

...

<Configure class="org.mortbay.jetty.handler.ContextHandler">
<Set name="contextPath">/static</Set>
<Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/static/</Set>
<Set name="handler">
  <New class="org.mortbay.jetty.handler.ResourceHandler">
    <Set name="cacheControl">max-age=3600,public</Set>
  </New>
 </Set>
</Configure>

Установленный значение contextPath с Вашим префиксом URL, и установленный значение resourceBase как путь к файлу статического содержания.

Это работало на меня.

35
задан Paolo Moretti 13 January 2012 в 10:27
поделиться

1 ответ

Ok figured it out. I posted a question on Goolge's Federated Log API group and was told to use Attribute exchange.

Below is the code for DotNetOpenAuth.

Please don't use this code in production. This is for illustration purposes only!

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();
}

The Response:

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);
            break;
        }
        ...
    }
}
52
ответ дан 27 November 2019 в 07:14
поделиться
Другие вопросы по тегам:

Похожие вопросы: