标签: dotnetopenauth

从OpenID提供商处请求电子邮件地址

我正在实现OpenID,我想检索用户的电子邮件地址和有关用户的其他信息,我这样做:

var fetch = new FetchRequest();
fetch.AddAttribute(new AttributeRequest(WellKnownAttributes.Contact.Email));
request.AddExtension(fetch);
Run Code Online (Sandbox Code Playgroud)

但提供者不会返回任何内容.我正在使用DotNetOpenID

我究竟做错了什么?

谢谢!

编辑:

当我尝试使用MyOpenID或Google 在http://www.plaxo.com/注册时,他们都说plaxo正在请求其他信息,但是当我测试我的网站时他们没有说什么......

openid dotnetopenauth

6
推荐指数
1
解决办法
2105
查看次数

claimsResponse返回Null

您好,我在asp.net中有以下代码.我使用DotNetOpenAuth.dll for openID.代码在

protected void openidValidator_ServerValidate(object source, ServerValidateEventArgs args)
{
    // This catches common typos that result in an invalid OpenID Identifier.
    args.IsValid = Identifier.IsValid(args.Value);
}

protected void loginButton_Click(object sender, EventArgs e)
{
    if (!this.Page.IsValid)
    {
        return; // don't login if custom validation failed.
    }
    try
    {
        using (OpenIdRelyingParty openid = this.createRelyingParty())
        {
            IAuthenticationRequest request = openid.CreateRequest(this.openIdBox.Text);

            // This is where you would add any OpenID extensions you wanted
            // to include in the authentication request.
            ClaimsRequest objClmRequest = new …
Run Code Online (Sandbox Code Playgroud)

c# openid dotnetopenauth

6
推荐指数
2
解决办法
2033
查看次数

DotNetOpenId - "此消息已被处理"错误(第2部分)

这已经在这里被问到了,但不是我和OP接受了一个对我没有帮助的答案.到目前为止,我已尝试从不同的浏览器登录,更改Web配置,清除Cookie以及从外部计算机加载.

事实上,我最终确实发现问题是我自己的机器特有的; 当我发布到另一台机器时,它工作正常.有关何处寻找解决方案的建议?我故意使用我能想到的最简单的测试代码,一个干净的空aspx页面和一个简单的Page_Load函数.

编辑:澄清,像原始问题的作者,我得到一个"此消息已被处理"错误.这是打印出来的屏幕Response.Write(response.Exception.ToString());.我相信这个问题与配置相关,与其他作者不同,因为症状只出现在我的本地方框中.请注意,症状与我是否在运行代码的同一个盒子上进行测试无关.

    protected void Page_Load(object sender, EventArgs e)
    {
        using (OpenIdRelyingParty openid = new OpenIdRelyingParty())
        {
            IAuthenticationResponse response = openid.GetResponse();
            if (response != null)
            {
                try
                {
                    Response.Write(response.Exception.ToString());
                }
                catch (Exception)
                {
                }
                return;
            }
        }

        using (OpenIdRelyingParty openid = new OpenIdRelyingParty())
        {
            IAuthenticationRequest request = openid.CreateRequest(@"https://www.google.com/accounts/o8/id");
            request.RedirectToProvider();
        }

    }
Run Code Online (Sandbox Code Playgroud)

错误信息:

DotNetOpenAuth.Messaging.Bindings.ReplayedMessageException:此消息已被处理.这可能表示正在进行重播攻击.位于c:\ TeamCity\buildAgent\work\bf9e2ca68b75a334\src\DotNetOpenAuth\Messaging\Bindings\StandardReplayProtectionBindingElement.cs中的DotNetOpenAuth.Messaging.Bindings.StandardReplayProtectionBindingElement.ProcessIncomingMessage(IProtocolMessage message):DotNetOpenAuth.Messaging.Channel.ProcessIncomingMessage(IProtocolMessage)第129行消息)在C:\ TeamCity的\ buildAgent \工作\ bf9e2ca68b75a334\SRC\DotNetOpenAuth \消息\ Channel.cs:线990在DotNetOpenAuth.OpenId.ChannelElements.OpenIdChannel.ProcessIncomingMessage(IProtocolMessage消息)在C:\ TeamCity的\ buildAgent \工作\ bf9e2ca68b75a334\src\DotNetOpenAuth\OpenId\ChannelElements\OpenIdChannel.cs:位于c:\ TeamCity\buildAgent\work\bf9e2ca68b75a334\src\DotNetOpenAuth\Messaging\Channel.cs中的DotNetOpenAuth.Messaging.Channel.ReadFromRequest(HttpRequestInfo httpRequest)的第172行:\TeamCity的\ buildAgent \工作\ bf9e2ca68b75a334\SRC\DotN:在DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.GetResponse(HttpRequestInfo httpRequestInfo在c)中线375 etOpenAuth\OpenId\RelyingParty\OpenIdRelyingParty.cs:第498行 …

.net c# openid dotnetopenauth

6
推荐指数
1
解决办法
2561
查看次数

如何设置DotNetOpenAuth的返回URL

我正在使用DotNetOpenAuth登录Facebook.
这是代码:

var facebookClient = new FacebookClient
{
    ClientIdentifier = "appId",
    ClientSecret = "appSecret"
};
IAuthorizationState authorization = facebookClient.ProcessUserAuthorization();
if (authorization == null)
{
    // Kick off authorization request
    facebookClient.RequestUserAuthorization();
}
else
{

    var request =
        WebRequest.Create("https://graph.facebook.com/me?access_token=" +
                            Uri.EscapeDataString(authorization.AccessToken));

    using (var response = request.GetResponse())
    {
        using (var responseStream = response.GetResponseStream())
        {
            var graph = FacebookGraph.Deserialize(responseStream);
            lblFacebookUserName.Text = HttpUtility.HtmlEncode(graph.Name);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

因为我正在使用自定义URL重写器,所以我在登录后收到错误,因为返回URL是类似的

〜/富/ foo.aspx?labg = EN

我希望它能够硬编码

〜/富/富

任何帮助,将不胜感激

c# asp.net dotnetopenauth

6
推荐指数
1
解决办法
1907
查看次数

使用Google Calendar Feed的DotNetOpenAuth

我试图通过使用DotNetOpenAuth从Google获取日历列表几天来绞尽脑汁.

我可以使用DotNetOpenAuth示例成功获取联系人列表.我已使用OpenId + OAuth将其与我的域集成.一切都很好,以获得联系人列表.

所以我从那里修改了代码以尝试检索日历列表,并且我一直收到401 Unauthorized错误.

我知道这是授权,因为我可以获得联系人列表.有没有人有一个代码示例如何使用Google的DotNetOpenAuth检索日历或日历事件?

谢谢

更新:

谢谢你的回复.我已经阅读了所有可以得到的东西.这是我到目前为止所做的

第1步:我在GoogleConsumer.cs中创建了一个新的GetCalendarEndPoint

private static readonly MessageReceivingEndpoint GetCalendarEndpoint = new MessageReceivingEndpoint("https://www.google.com/calendar/feeds/default", HttpDeliveryMethods.GetRequest);
Run Code Online (Sandbox Code Playgroud)

第2步:接下来,我在GoogleConsumer.cs中的GetContacts方法之后创建了一个新方法GetCalendars - (重建了dll等)

    public static XDocument GetCalendars(ConsumerBase consumer, string accessToken, int maxResults/* = 25*/, int startIndex/* = 1*/) {
            if (consumer == null)
            {
                throw new ArgumentNullException("consumer");
            }

            var request = consumer.PrepareAuthorizedRequest(GetCalendarEndpoint, accessToken);
            var response = consumer.Channel.WebRequestHandler.GetResponse(request);
            string body = response.GetResponseReader().ReadToEnd();
            XDocument result = XDocument.Parse(body);
            return result;
Run Code Online (Sandbox Code Playgroud)

第3步:在我的应用程序中,我将ScopeURI从GoogleConsumer修改为Calendar URI,如下所示

private IAuthenticationRequest GetGoogleRequest()
{
    Realm realm = Request.Url.Scheme + Uri.SchemeDelimiter + …
Run Code Online (Sandbox Code Playgroud)

c# asp.net oauth google-calendar-api dotnetopenauth

6
推荐指数
1
解决办法
1478
查看次数

DotNetOpenAuth是否支持刷新过期访问令牌?

我找不到使用DotNetOpenAuth 刷新过期的访问令牌的任何示例.大多数提供商不使用过期令牌,但雅虎是一个在一小时内使其令牌到期的大型提供商.

谢谢!

c# oauth dotnetopenauth

6
推荐指数
2
解决办法
1879
查看次数

Html.OpenIdSelectorScripts抛出NullReferenceException的helper方法

尝试导航到LogOn页面时,我不断收到此错误:

System.NullReferenceException:未将对象引用设置为对象的实例

抛出错误的代码行是:

<%= Html.OpenIdSelectorScripts(this, options, null)%>. 
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么这行代码会抛出错误?

c# asp.net asp.net-mvc nullreferenceexception dotnetopenauth

6
推荐指数
1
解决办法
635
查看次数

6
推荐指数
1
解决办法
3683
查看次数

jquery移动取消302重定向到外部站点

我正在尝试将DotNetOpenAuth与使用jquery mobile的网站集成.我遇到了一个问题,即jquery mobile似乎取消了302重定向到服务器响应的提供方(外部站点).

我已经尝试在mobileinit事件中使用以下内容关闭默认的jquery mobile ajax处理:

$.mobile.ajaxEnabled = false;
Run Code Online (Sandbox Code Playgroud)

如果我从图片中取出jquery mobile,则正确处理302重定向,并且与提供方的OpenID集成工作正常.

任何人都可以告诉我如何让jquery mobile正确处理302重定向到外部网站?

dotnetopenauth jquery-mobile

6
推荐指数
1
解决办法
2259
查看次数

C#,.NET中的Google Api OAuth

我只想使用Gmail OAuth身份验证登录我开发的应用程序,我需要列出其中的各种输入,例如

  1. 名字
  2. 电子邮件地址
  3. 杜伯

我使用的第三方是:DotNetOpenAuth.dll

我用Google搜索并没有找到任何解决方案?

等待您的宝贵意见和建议

.net c# oauth dotnetopenauth google-oauth

6
推荐指数
1
解决办法
1万
查看次数