How to create microsoft app password using API?

谁说我不能喝 提交于 2019-12-13 03:26:26

问题


I'm able to create app id using Graph API but app secret/password is not generated with it. I need a way to generate/set a password using APIs.

Am I missing something?


回答1:


You could create the password via Azure AD Graph API, you can test it in the AAD Graph Explorer.

My test sample:

Request URL:

PATCH https://graph.windows.net/{tenant id}/applications/{application object id}?api-version=1.6 

Request body:

{
    "passwordCredentials": [{
        "endDate": "2020-08-12T02:54:44.2530506Z",
        "keyId": "77fe4bf5-5d04-4a62-abc2-f064a9213d3f",
        "startDate": "2019-08-12T02:54:44.2530506Z",
        "customKeyIdentifier": "dGVzdA==",
        "value": "XnkNIsT+cScOYeYJayQ4WNmp9tgAqw5z773uI9WQtAw="
    }]
}

For more details about the request body, refer to this link - PasswordCredential.

Note: In the AAD Graph Explorer, when you send the request, the progress bar will never finish, but actually it works, you could check the result in the portal -> Azure Active Directory after a while.

Besides, there is also a Beta api in Microsoft Graph - Update application, I have not tested it, so I am not sure if it works. It is a Beta version, even if it works, I don't recommend you to use it in the production environment.




回答2:


Are you following the correct API link?

Create User

It is easy to create Azure AD users using the Microsoft Graph REST. Here is a code sample for your reference:

POST https://graph.microsoft.com/v1.0/users 
Authorization: Bearer {token}
Content-type: application/json

{
  "accountEnabled": true,
  "displayName": "Sajee",
  "mailNickname": "Sinna",
  "userPrincipalName": "upn-value@tenant-value.onmicrosoft.com",
  "passwordProfile" : {
    "forceChangePasswordNextSignIn": true,
    "password": "password-value"
  }
}


来源:https://stackoverflow.com/questions/57441904/how-to-create-microsoft-app-password-using-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!