在我的c#应用程序中,我正在尝试使用facebook c#sdk获取用户的accessstoken /身份验证令牌。 如果我使用response_type ='code',那么我在回调函数中获取数据,但是当我使用response_type ='token'时,数据将变为null。 当我使用response_type ='code'
时,贝娄是我的代码 private Uri RedirectUri
{
get
{
var uriBuilder = new UriBuilder(Request.Url);
uriBuilder.Query = null;
uriBuilder.Fragment = null;
uriBuilder.Path = Url.Action("FacebookCallback");
return uriBuilder.Uri;
}
}
public ActionResult FacebookLogin()
{
var fb = new FacebookClient();
var loginUrl = fb.GetLoginUrl(new
{
client_id = "146137372750966",
client_secret = "",
redirect_uri = RedirectUri.AbsoluteUri,
response_type = "code",
scope = "public_profile,email",
state = "gsdfgjpfosd34956834"
});
return Redirect(loginUrl.AbsoluteUri);
}
public ActionResult FacebookCallback(string code)
{
}
当我使用response_type ='token'
时,Bellow是代码private Uri RedirectUri
{
get
{
var uriBuilder = new UriBuilder(Request.Url);
uriBuilder.Query = null;
uriBuilder.Fragment = null;
uriBuilder.Path = Url.Action("FacebookCallback");
return uriBuilder.Uri;
}
}
public ActionResult FacebookLogin()
{
var fb = new FacebookClient();
var loginUrl = fb.GetLoginUrl(new
{
client_id = "146137372750966",
client_secret = "",
redirect_uri = RedirectUri.AbsoluteUri,
response_type = "token",
scope = "public_profile,email",
state = "gsdfgjpfosd34956834"
});
return Redirect(loginUrl.AbsoluteUri);
}
public ActionResult FacebookCallback(string code)
{
}
传递response_type =“token”,
时,我无法识别我正在做的错误返回的网址是这样的。
http://localhost:32432/FacebookCallback?#state=gsdfgjpfosd34956834&access_token=lfahfegldskgjsdgdslkkghlsgfsgmndf;lhjd&expires_in=3927
如何在回调函数中阅读此内容?