【发布时间】:2020-05-11 07:12:49
【问题描述】:
我想做的是让用户在他们的 Windows 桌面计算机上登录到 AAD 提示符,这样我就得到了一个可以与我的 Azure 函数一起使用的 Bearer 令牌。
我已按照this article on adatum 的教程进行操作,但它仅涵盖应用程序权限(不包括委派权限)
- 我已经有一个为 Azure AD 设置的 Azure 函数 验证。
- 我已经有一个我注册的客户端应用程序(在
应用程序注册)。
- 我已将其配置为使用委派权限 用于 Azure 函数。
这是我的客户端代码:
var clientId = "client id for my console app";//console app
var clientUrl = new Uri("https://login.microsoftonline.com/common/oauth2/nativeclient");
var tenant = "tenantid here";
string authority = "https://login.windows.net/" + tenant;
string resource = "https://myaadProtectedFunc.azurewebsites.net";
AuthenticationContext authenticationContext = new AuthenticationContext(authority, false);
var pp = new PlatformParameters(PromptBehavior.Auto);
var token = authenticationContext.AcquireTokenAsync(resource, clientId, clientUrl,
pp, UserIdentifier.AnyUser).Result;
Console.WriteLine("Got the token: {0}", token.AccessToken);
我收到一条错误消息,提示“[我的客户端应用程序] 需要访问您组织中只有管理员才能授予的资源的权限。请让管理员授予此应用程序的权限,然后您才能使用它。”
是否有其他方法可以获取适用于我的 Azure Function 的 Bearer 令牌?
【问题讨论】:
标签: c# powershell azure-functions adal