[英]how to get access token after windows azure active directory authentication
we have successfully implemented the active directory authentication using the process given at the url http://msdn.microsoft.com/en-us/library/windowsazure/dn151790.aspx . 我们已经使用URL http://msdn.microsoft.com/zh-cn/library/windowsazure/dn151790.aspx上给出的过程成功地实现了活动目录身份验证。 Here we are able to authenticate the user on the https://login.microsoftonline.com/ and return back to web site but we are not able to get access token after successful authentication.
在这里,我们能够在https://login.microsoftonline.com/上对用户进行身份验证,然后返回到网站,但是成功进行身份验证后,我们将无法获得访问令牌。 following code through which we are able to access the user name, surname etc after successful authentication but not the access token.
以下代码,通过它们我们可以在成功认证后访问用户名,姓氏等,但不能访问令牌。 can you provide me the code through which we can get the access token after authentication.
您能否提供给我代码,以便我们在身份验证后通过该代码获得访问令牌。
public class HomeController : Controller
{
public ActionResult Index()
{
ClaimsPrincipal cp = ClaimsPrincipal.Current;
string fullname =
string.Format("{0} {1}", cp.FindFirst(ClaimTypes.GivenName).Value,
cp.FindFirst(ClaimTypes.Surname).Value);
ViewBag.Message = string.Format("Dear {0}, welcome to the Expense Note App",
fullname);
return View();
}
}
You can use this code to access the security token that was used: 您可以使用以下代码访问所使用的安全令牌:
ClaimsPrincipal cp = ClaimsPrincipal.Current;
ClaimsIdentity ci = cp.Identity as ClaimsIdentity;
BootstrapContext bc = ci.BootstrapContext as BootstrapContext;
SecurityToken securityToken = bc.SecurityToken;
You also need to set the saveBootstrapContext attribute in your config file: 您还需要在配置文件中设置saveBootstrapContext属性:
<system.identityModel>
<identityConfiguration saveBootstrapContext="true">
...
</system.identityModel>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.