身份验证响应失败 [英] Authentication Response Failed
本文介绍了身份验证响应失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友,
我想从社交网络获取用户信息.
我已经编写了用于使用OpenID获取信息的代码.
但是我收到登录失败"的消息.
Dear Friends,
I want get information of the user from social network.
I have written a code for getting the information using OpenID.
But I am getting the message as Login Failed.
DotNetOpenAuth.OpenId.RelyingParty.FailedAuthenticationResponse
代码:
Code:
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.RelyingParty;
using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OpenIdRelyingParty rp = new OpenIdRelyingParty();
var response = rp.GetResponse();
var st = "";
var msg = "";
if (response != null)
{
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
Session["GoogleIdentifier"] = response.ClaimedIdentifier.ToString();
st= response.ClaimedIdentifier.ToString();
msg = response.ToString();
Response.Redirect("Default.aspx");
break;
case AuthenticationStatus.Canceled:
Session["GoogleIdentifier"] = "Cancelled.";
st = "Cancelled.";
msg = response.ToString();
break;
case AuthenticationStatus.Failed:
Session["GoogleIdentifier"] = "Login Failed.";
st = "Login Failed.";
msg = response.ToString();
break;
}
}
if (st!= "")
{
Label1.Text = st;
Label2.Text = msg;
}
}
//Onclick of Icon
protected void btnGL_Click(object sender, CommandEventArgs e)
{
string GLUri = e.CommandArgument.ToString();
OpenIdRelyingParty oid = new OpenIdRelyingParty();
var Uribuilder = new UriBuilder(Request.Url) { Query = "" };
var request = oid.CreateRequest(GLUri, Uribuilder.Uri, Uribuilder.Uri);
request.RedirectToProvider();
}
}
请提出相同的建议并给出解决方案.
谢谢.
Kindly suggest and give solution for the same.
Thanks.
推荐答案
看看这些示例示例,了解如何使用OAuth使用社交网络登录:
在OAuth 2.0中使用Web API [与Facebook和Camp的C#应用程序集成带有oAuth的Twitter [ ^ ]
尝试看看是否有帮助!
Have a look at these sample examples on how to use social network login using OAuth:
Using Web APIs with OAuth 2.0[^]
C# Application Integration with Facebook & Twitter with oAuth[^]
Try and see if it helps!
这篇关于身份验证响应失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文