asp.net-web-api - 受 Azure AD B2C 保护的自动化端点测试

标签 asp.net-web-api azure-active-directory azure-ad-b2c

我有一个 WebAPI 应用程序,它使用用户通过使用凭据登录获得的 Azure B2C token 进行身份验证。

我现在需要针对我的 WebAPI 编写一些测试,但我不确定如何自动获取 token ,因为我需要登录 https://login.microsoftonline.com ...

缺少使用 selenium 或其他东西来登录 - 是否有另一种选择来获取要使用的 token ?

最佳答案

我假设您想以非交互式方式获取 token 。

我想你可以用 resource owner password credentials flow in AAD B2C .

注意:在 Azure Active Directory (Azure AD) B2C 中,支持以下选项:

  • Native Client: User interaction during authentication happens when code runs on a user-side device. The device can be a mobile application that's running in a native operating system, such as Android, or running in a browser, such as JavaScript.

  • Public client flow: Only user credentials, gathered by an application, are sent in the API call. The credentials of the application are not sent.

  • Add new claims: The ID token contents can be changed to add new claims.



此流程可以让您无需 UI 即可获取 token 。

此外,AAD B2C 目前不支持客户端凭据流和 OAuth 2.0 JWT 不记名凭据授予,也称为代表流。您可以看到限制 in this documentation .

关于asp.net-web-api - 受 Azure AD B2C 保护的自动化端点测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51079730/

相关文章:

c# - 类型 'Api.Controllers.' 没有默认构造函数

powershell - 使用 Powershell New-AzureADUser 创建 Azure AD B2C 本地帐户用户

azure - 将 Exchange Online powershell v3 连接到 Multi-Tenancy 应用程序中的委派访问

python - 如何允许非管理员用户通过 OAuth2.0 为不允许用户代表他们同意应用程序的租户进行身份验证?

ios - MSAL 从 iOS Swift 示例返回错误 token

Azure AD B2C、Sendgrid - 请求者的 IP 地址未列入白名单

javascript - Breeze js - 如何从 JSON 字符串创建实体并将其导入到 Breeze 缓存中

asp.net - POST 到 web api 时不支持的媒体类型

asp.net - 缺少 Web API Controller 类模板 VS 2010

azure - 无法将 Azure AD 管理员添加到具有专用访问权限的 Azure Database for PostgreSQL 灵活服务器(VNet 集成)