【问题标题】:Get Azure AD access token from VSTS?从 VSTS 获取 Azure AD 访问令牌?
【发布时间】:2018-06-20 13:24:27
【问题描述】:

我有一些单元测试 (JavaScript) 将被触发以从 VSTS 运行。这些测试将测试一些托管在 Azure 中的 Web api 端点,并在 Web api webapp 上配置了 Azure AD 身份验证。

在客户端(VSTS 中的 JS 代码)需要对 Azure AD webapp(非本机应用)执行非交互式身份验证以获取访问令牌的情况下,谁能推荐针对 Azure AD 进行身份验证的最佳方法?

有没有办法以这种方式获取访问令牌(无需在向 Azure 令牌端点的请求中传递查询字符串参数中的凭据,我很欣赏这将起作用,但远非理想)?

【问题讨论】:

    标签: azure azure-devops azure-active-directory access-token adal


    【解决方案1】:

    您可以使用Azure service principal

    【讨论】:

    • 我已经设置了服务主体。我会使用哪个,但我不确定最适合需要以非交互方式获取访问令牌的 JS 测试的身份验证流程/过程。
    【解决方案2】:

    参考这篇文章在JS中使用Azure服务主体:Using the service principal

    const Azure = require('azure');
    const MsRest = require('ms-rest-azure');
    
    MsRest.loginWithServicePrincipalSecret(
      <clientId or appId>,
      <secret or password>,
      <domain or tenant>,
      (err, credentials) => {
        if (err) throw err
    
        let storageClient = Azure.createARMStorageManagementClient(credentials, '<azure-subscription-id>');
    
        // ..use the client instance to manage service resources.
      }
    );
    

    【讨论】:

      猜你喜欢
      • 2019-05-15
      • 1970-01-01
      • 2021-11-13
      • 2022-01-05
      • 1970-01-01
      • 2019-08-31
      • 2020-12-21
      • 1970-01-01
      • 2019-01-27
      相关资源
      最近更新 更多