tou*_*ili 0 azure azure-ad-b2c
遵循本教程, 我可以使用ADAL创建用户,从而使该方案在ADB2C上正常工作。(这是该场景的上下文)
我的目标是发送用户邀请(电子邮件)以使他加入我的appp。
我发现在graph.microsoft.com(MS图而不是AD图)上,有一个可用于此目的的邀请管理器,并且可能是如果您在B2C Azure门户上创建用户时触发邀请的方式。
我是否应该以与AD相同的方式获取MS图上的令牌
var authenticationContext = new AuthenticationContext(AuthString,false);
var clientCred = new ClientCredential(ClientId,ClientSecret);
var authenticationResult = authenticationContext.AcquireTokenAsync(ResourceUrl,clientCred);
var令牌= authenticationResult.Result.AccessToken;
这一次ResourceUrl指向https://graph.microsoft.com
这是我的OwinOpenID AuthenticationCodeReceived回调:
AuthorizationCodeReceived = async (context) =>
{
// get authentication context
string userObjectID = context.AuthenticationTicket.Identity.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
AuthenticationContext authContext = new AuthenticationContext($"https://login.microsoftonline.com/{AuthenticationHelper.Tenant}", new NaiveSessionCache(userObjectID));
ClientCredential credential = new ClientCredential(AuthenticationHelper.ClientId, AuthenticationHelper.AppKey);
AuthenticationResult result = await authContext.AcquireTokenAsync("https://graph.windows.net", credential);
// ----> Token used on the authorization header for AD user management and work properly
AuthenticationHelper.Token = result.AccessToken;
// Token for MS graph
ClientCredential MSCredential = new ClientCredential(AuthenticationHelper.MSClientId, AuthenticationHelper.MSAppKey);
AuthenticationResult resultMSGraph = await authContext.AcquireTokenAsync("https://graph.microsoft.com", MSCredential);
// ----> Token used on the authorization header for MS Graph and is not working !!
AuthenticationHelper.MSGraphToken = resultMSGraph.AccessToken;
},
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助
Azure AD B2C不支持Microsoft Graph上的邀请管理器API。 目前,邀请管理器API适用于企业/常规Azure AD租户邀请其他用户作为访客(请参阅Azure AD B2B Collaboration)。
Azure AD B2C UserVoice论坛中已经存在一个条目,要求能够发送电子邮件邀请以供新用户注册。我建议您为该条目投票,以帮助我们确定优先级,并随时了解其进度。
在此期间,您必须自己实施此过程,无论是简单的欢迎电子邮件还是更复杂的“兑换代码”工作流程。
| 归档时间: |
|
| 查看次数: |
624 次 |
| 最近记录: |