Azure CLI 使用 AllowImplicit 创建 AD 应用程序

Azure CLI Create AD App with AllowImplicit

有什么方法可以创建或修改 AzureAD 应用程序以允许通过 Azure CLI 2.0 的 OAuth 2.0 隐式流?

我可以使用 az ad app create

创建应用程序注册而不会出现问题

看起来 Azure CLI 2.0 没有公开要设置的 OAuth2AllowImplicitFlow 属性,但是 Azure Active Directory PowerShell 2.0 确实公开了这个 属性:

-Oauth2AllowImplicitFlow

Specifies whether this web application can request OAuth2.0 implicit flow tokens. The default is false.

Type: Boolean

Position: Named

Default value: None

Accept pipeline input: False

Accept wildcard characters: False

如果有帮助请告诉我。

您可以使用 CLI 调用 Graph API 来实现这一点。此方法需要在您的 AAD 租户中创建 service principal,并为其分配 Company Admin role

获取身份验证令牌

curl -X "POST" "https://login.microsoftonline.com/$TENANTID/oauth2/token" \
-H "Cookie: flight-uxoptin=true; stsservicecookie=ests; x-ms-gateway-slice=productionb; stsservicecookie=ests" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "client_id=$APPID" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "client_secret=$PASSWORD" \
--data-urlencode "resource=https://graph.windows.net/"

将 AAD 应用程序 Oauth2AllowImplicitFlow 设置为 true:

curl -X "PATCH" "https://graph.windows.net/$TENANTID/applications/$ObjectId?api-version=1.6" \
    -H "Authorization: Bearer $ACCESSTOKEN" \
    -H "Content-Type: application/json" \
    -d $'{"oauth2AllowImplicitFlow":true}'

几秒钟后,您的应用程序的 Oauth2AllowImplicitFlow 已设置为 true。

额外的,如@Shawn said that Azure CLI doesn't have this cmdlet to set AAD Application,but Azure Powershell have. However Azure CLI is an important tool for Linux platform to use Azure. I think we can post this feature feedback in this Page。 Azure 团队将对其进行审查。

希望对您有所帮助!