How to set the UserInfo of a ADAL Token

谁都会走 提交于 2019-12-22 18:40:13

问题


So im building a ASP.NET web app that uses ADAL with Office 365 but I would like to have ADAL save the tokens so that the user will not have to log into Office each Session.
I've looked all over the place and have figured out how to implement a token cache but I still don't know how to create the token with the current Users info so that I can retrieve it.
Im sure it's as simple as adding a argument to one of the AcquireToken methods but I cant find out how. For referance this is what I have so far in terms of ADAL

Uri authUri = await authContext.GetAuthorizationRequestUrlAsync(scopes,null, clientId,
            redirectUri, new UserIdentifier(User.Identity.GetUserId(), UserIdentifierType.RequiredDisplayableId),null);

AuthenticationContext authContext = new AuthenticationContext(authority, cache);
var authResult = await authContext.AcquireTokenByAuthorizationCodeAsync(
                authCode, redirectUri, credential, scopes);

And I want to call this

var authResult = await authContext.AcquireTokenSilent(
scopes, clientId, new UserIdentifier(User.Identity.GetUserId(), UserIdentifierType.UniqueId)
);

But none of the Tokens have any user info on them

If you need any other info feel free to ask, thanks

来源:https://stackoverflow.com/questions/34849612/how-to-set-the-userinfo-of-a-adal-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!