如何以编程方式指定replyUrlsWithType

时间:2019-11-04 00:29:05

标签: azure-active-directory

我想以编程方式在Azure AD中的应用manifest上设置replyUrlsWithType。但是,用于更新manifest的REST API似乎仅支持设置replyUrls属性,该属性不能设置type属性。是否可以通过编程方式设置replyUrlsWithType

我正在与之合作的团队使用Fiddler来研究Azure门户如何设置type属性,并破解了以下内容以使其起作用,但如果有一种方法,我们正在寻找一种受支持的方法:

$UpdateAppResponse = Invoke-WebRequest -Uri "https://graph.windows.net/myorganization/applications/$appId?api-version=2.0" `
    -Method "PATCH" `
    -Headers @{"Authorization"="$($Response.token_type) $($Response.access_token)"; "Accept"="*/*"; } `
    -ContentType "application/json" `
    -Body "{`"id`":`"$appId`",`"replyUrlsWithType`":[{`"url`":`"https://$HostName`",`"type`":`"Web`"},{`"url`":`"msauth://$ReversedHostName`",`"type`":`"InstalledClient`"}, {`"url`":`"msauth.$ReversedHostName://auth`",`"type`":`"InstalledClient`"}]}"

2 个答案:

答案 0 :(得分:1)

过去,在Azure门户中注册的应用程序只能是一种类型。因此,Azure AD Graph API能够设置replyUrls

但是,在Azure门户中注册的新应用程序可以同时支持两种类型。根据提琴手的踪迹,Azure AD Graph似乎已更新以支持该功能。

URL https://graph.windows.net/myorganization/applications/$appId?api-version=2.0是AAD Graph API的典型URL。也许只是文档尚未更新。


但是,我们建议您使用Microsoft Graph API。它是用于管理大量Microsoft Cloud资源的统一中心。

您可以使用Microsoft Graph API Get applicationUpdate application

例如,您可以使用以下正文发出PATCH请求:

{
    "publicClient": {
        "redirectUris": [
            "myapp://auth"
        ]
    },
    "web": {
        "redirectUris": [
            "https://devchat.com/",
            "http://localhost/",
            "https://mytest.com/"
        ],
        "implicitGrantSettings": {
            "enableAccessTokenIssuance": false,
            "enableIdTokenIssuance": false
        }
    }
}

然后将添加所有平台:

enter image description here

答案 1 :(得分:0)

对于希望像 SPA 一样进行类似配置的任何人,您可以将该属性设置为 "spa" 而不是 "web"。这让我很头疼,所以希望对其他人有帮助:

代替:

"web": {
    "redirectUris": [

使用

"spa": {
    "redirectUris": [

Azure Cloud Shell (bash) 的单层:

az rest --method PATCH --uri 'https://graph.microsoft.com/v1.0/applications/<APP REG OBJECT GUID (object ID not the App ID)>' --headers 'Content-Type=application/json' --body '{"spa":{"redirectUris":["https:<APP DOMAIN (and port if needed)>"]}}'
相关问题