當前,當我有一個新環境的請求時,我正在手動在Azure Active目錄上創建我的應用程序。我正在探索通過REST API從代碼創建這些應用程序的方法。通過使用'client_credentials',我成功地在現有應用程序上創建用戶和組,如圖所示。如何以編程方式在Azure中創建應用程序AD
ClientCredential clientCred = new ClientCredential(clientID, clientSecret);
AuthenticationResult authenticationResult = await authenticationContext.AcquireTokenAsync(resAzureGraphAPI, clientCred);
以類似的方式我試圖用從上面的「ACCESS_TOKEN」中產生以創建一個新的應用程序 adClient.Applications.AddApplicationAsync(newApplication).Wait()
但這引發無錯誤「沒有足夠的權限來完成操作。「
我查看了其他線程和Azure AD msdn頁面,結果發現client_credentials流程不支持創建/更新應用程序。
Adding Applications programmatically in Azure AD using Client Credentials Flow
上述線程還提到的方式來解決辦法是通過使用「grant_type =密碼」流動。我按照建議嘗試了,但是我不斷收到以下錯誤,這對我沒有任何意義。
"error": "invalid_grant",
"error_description": "AADSTS50034: To sign into this application the account must be added to the 1283y812-2u3u-u293u91-u293u1 directory.\r\nTrace ID: 66da9cf9-603f-4f4e-817a-cd4774619631\r\nCorrelation ID: 7990c26f-b8ef-4054-9c0b-a346aa7b5035\r\nTimestamp: 2016-02-21 23:36:52Z",
"error_codes": [
50034
],
這是有效載荷和我打的端點。傳遞的用戶是我想創建應用程序的AD的所有者
endpoint:https://login.windows.net/mytenantID/oauth2/token
post data
resource 00000002-0000-0000-c000-000000000000
client_id id
client_secret secret
grant_type password
username [email protected]
password password
scope openid
任何有關我可能會出錯的想法或建議將不勝感激。
我第一次用'連接,MsolService'登錄連接。 'Get-MsolRole'列出了一堆角色和他們的名字。然後我想檢查我的角色。所以我解僱了'Get-MsolUserRole -UserPrincipalName test @ mydomain.com'。這返回空。當我開始創建'New-MsolServicePrinicpal'時,我總是得到錯誤 - _Access被拒絕。您無權訪問此cmdlet._ – Srikanth