如何从 URL 解析访问令牌
我得到以下 URL:
http://localhost:8080/facebook/Status#access_token=dsadsa
我尝试在方法 Status() 中解析它,但变量“Request.Url”是
http://localhost:8080/facebook/Status
如何解决这个问题?
public ActionResult Status()
{
FacebookOAuthResult result;
if (FacebookOAuthResult.TryParse(Request.Url, out result))
{
if (result.IsSuccess)
{
var accessToken = result.AccessToken;
var code = result.Code;
var app = new FacebookClient(fbm.appID, fbm.appSecret);
fbm.accessToken = app.AccessToken;
ViewData["accessToken"] = app.AccessToken;
fbm.isAuthorized = true;
}
else
{
var errorDesc = result.ErrorDescription;
var errorReason = result.ErrorReason;
fbm.isAuthorized = false;
ViewData["errorDesc"] = errorDesc;
ViewData["errorReason"] = errorReason;
}
}
return View();
}
I get the following URL:
http://localhost:8080/facebook/Status#access_token=dsadsa
I trying parse it in method Status() but variable "Request.Url" is
http://localhost:8080/facebook/Status
How to solve this problem ?
public ActionResult Status()
{
FacebookOAuthResult result;
if (FacebookOAuthResult.TryParse(Request.Url, out result))
{
if (result.IsSuccess)
{
var accessToken = result.AccessToken;
var code = result.Code;
var app = new FacebookClient(fbm.appID, fbm.appSecret);
fbm.accessToken = app.AccessToken;
ViewData["accessToken"] = app.AccessToken;
fbm.isAuthorized = true;
}
else
{
var errorDesc = result.ErrorDescription;
var errorReason = result.ErrorReason;
fbm.isAuthorized = false;
ViewData["errorDesc"] = errorDesc;
ViewData["errorReason"] = errorReason;
}
}
return View();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在此处看到 ASP.NET:解析具有 #(哈希)符号的 url 表明请求对象不包含哈希标签。
You can see here ASP.NET: parse url having # (hash) sign that the request object does not contain the hash tag.