In this article, we will discuss about How to use Azure Active Directory Graph API.
Note:- Before starting using we have to register a new app in Azure Active Directory and then need to assign Permissions, after that we are able to get Client ID, Client Secret, Object ID
Prerequisite:
i. Client ID
ii. Client Secret
iii. Object ID
iv. Azure Account User details (Username and Password)
So, let's discuss step by step:
Login to Azure AD: -
{
"name": "Login",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "client_id",
"value": "036d42bc-2b3f-41da-a302-29d09eac37eb",
"type": "text"
},
{
"key": "client_secret",
"value": "k=dZOh.RZL[0334j:A=Tx.K5bVMEx:.G",
"type": "text"
},
{
"key": "username",
"value": "sam@saddamk206.onmicrosoft.com",
"type": "text"
},
{
"key": "password",
"value": "Pak11929",
"type": "text"
},
{
"key": "grant_type",
"value": "password",
"type": "text"
},
{
"key": "resource",
"value": "https://graph.microsoft.com",
"type": "text"
},
{
"key": "scope",
"value": "openid",
"type": "text"
}
]
},
"url": {
"raw": "https://login.microsoftonline.com/78a74a06-7d8f-4205-95ca-836e6937e795/oauth2/token?",
"protocol": "https",
"host": [
"login",
"microsoftonline",
"com"
],
"path": [
"78a74a06-7d8f-4205-95ca-836e6937e795",
"oauth2",
"token"
],
"query": [
{
"key": "",
"value": null
}
]
}
},
"response": []
}
New User Registration:
{
"name": "create",
"request": {
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "addTokenTo",
"value": "header",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-type",
"value": "application/json",
"type": "text"
},
{
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
"key": "Authorization",
"value": "Bearer <Token>",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "\r\n{\r\n \"accountEnabled\": true,\r\n \"displayName\": \"sam khan\",\r\n \"mailNickname\": \"sam\",\r\n \"userPrincipalName\": \"samk1@saddamk206.on microsoft.com\",\r\n \"passwordProfile\" : {\r\n \"forceChangePasswordNextSignIn\": true,\r\n \"password\": \"Pass@word1\"\r\n }\r\n}\r\n\r\n\r\n"
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/users",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"users"
]
}
},
"response": []
}
Edit User Details:
{
"name": "Edit User",
"request": {
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "addTokenTo",
"value": "header",
"type": "string"
}
]
},
"method": "PATCH",
"header": [
{
"key": "Content-type",
"value": "application/json",
"type": "text"
},
{
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
"key": "Authorization",
"value": "Bearer <Token>",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "\r\n{\r\n \"givenName\": \"sam\",\r\n \"jobTitle\": \"Dynamics Architect\",\r\n \"mobilePhone\": \"9988776600\",\r\n \"officeLocation\": \"India\",\r\n \"preferredLanguage\": \"en-us\",\r\n \"surname\": \"Khan\"\r\n}\r\n\r\n\r\n"
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/users/57e64c5f-cf09-4b85-be69-a589057d4a34",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"users",
"57e64c5f-cf09-4b85-be69-a589057d4a34"
]
}
},
"response": []
}
Update Password:
{
"name": "Update password",
"request": {
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "addTokenTo",
"value": "header",
"type": "string"
}
]
},
"method": "PATCH",
"header": [
{
"key": "Content-type",
"value": "application/json",
"type": "text"
},
{
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
"key": "Authorization",
"value": "Bearer <Token>",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": " {\r\n \"passwordProfile\": {\r\n \"forceChangePasswordNextSignIn\": false,\r\n \"password\": \"mQht3Wthnj2\"\r\n }\r\n }"
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/users/57e64c5f-cf09-4b85-be69-a589057d4a34",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"users",
"57e64c5f-cf09-4b85-be69-a589057d4a34"
]
}
},
"response": []
}
Get License:
{
"name": "Get license",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "addTokenTo",
"value": "header",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Content-type",
"value": "application/json",
"type": "text"
},
{
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
"key": "Authorization",
"value": "Bearer <Token>",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/a4cb01c0-f5d2-4787-8cbf-9726cdd8466c/subscribedSkus",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"a4cb01c0-f5d2-4787-8cbf-9726cdd8466c",
"subscribedSkus"
]
}
},
"response": []
}
Assign License:
{
"name": "assign license",
"request": {
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "addTokenTo",
"value": "header",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-type",
"value": "application/json",
"type": "text"
},
{
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
"key": "Authorization",
"value": "Bearer <Token>",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"addLicenses\": [\r\n {\r\n \"disabledPlans\": [ ],\r\n \"skuId\": \"4b9405b0-7788-4568-add1-99614e613b69\"\r\n }\r\n ],\r\n \"removeLicenses\": [ ]\r\n}"
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/users/a4cb01c0-f5d2-4787-8cbf-9726cdd8466c/assignLicense",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"users",
"a4cb01c0-f5d2-4787-8cbf-9726cdd8466c",
"assignLicense"
]
}
},
"response": []
}
Enable-Disable User Account:
{
"name": "Enable-Disable User Account",
"request": {
"method": "PATCH",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "Authorization",
"value": "Bearer <Token>",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"accountEnabled\": true\r\n}",
"options": {
"raw": {
"language": "javascript"
}
}
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/users/655f60c8-66db-4c7c-a87b-76680e7f89a7",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"users",
"655f60c8-66db-4c7c-a87b-76680e7f89a7"
]
}
},
"response": []
}
Thanks for reading the article. Hope this Article will helpful for you. Cheers!!!
Note:- Before starting using we have to register a new app in Azure Active Directory and then need to assign Permissions, after that we are able to get Client ID, Client Secret, Object ID
Prerequisite:
i. Client ID
ii. Client Secret
iii. Object ID
iv. Azure Account User details (Username and Password)
So, let's discuss step by step:
Login to Azure AD: -
{
"name": "Login",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "client_id",
"value": "036d42bc-2b3f-41da-a302-29d09eac37eb",
"type": "text"
},
{
"key": "client_secret",
"value": "k=dZOh.RZL[0334j:A=Tx.K5bVMEx:.G",
"type": "text"
},
{
"key": "username",
"value": "sam@saddamk206.onmicrosoft.com",
"type": "text"
},
{
"key": "password",
"value": "Pak11929",
"type": "text"
},
{
"key": "grant_type",
"value": "password",
"type": "text"
},
{
"key": "resource",
"value": "https://graph.microsoft.com",
"type": "text"
},
{
"key": "scope",
"value": "openid",
"type": "text"
}
]
},
"url": {
"raw": "https://login.microsoftonline.com/78a74a06-7d8f-4205-95ca-836e6937e795/oauth2/token?",
"protocol": "https",
"host": [
"login",
"microsoftonline",
"com"
],
"path": [
"78a74a06-7d8f-4205-95ca-836e6937e795",
"oauth2",
"token"
],
"query": [
{
"key": "",
"value": null
}
]
}
},
"response": []
}
New User Registration:
{
"name": "create",
"request": {
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "addTokenTo",
"value": "header",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-type",
"value": "application/json",
"type": "text"
},
{
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
"key": "Authorization",
"value": "Bearer <Token>",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "\r\n{\r\n \"accountEnabled\": true,\r\n \"displayName\": \"sam khan\",\r\n \"mailNickname\": \"sam\",\r\n \"userPrincipalName\": \"samk1@saddamk206.on microsoft.com\",\r\n \"passwordProfile\" : {\r\n \"forceChangePasswordNextSignIn\": true,\r\n \"password\": \"Pass@word1\"\r\n }\r\n}\r\n\r\n\r\n"
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/users",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"users"
]
}
},
"response": []
}
Edit User Details:
{
"name": "Edit User",
"request": {
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "addTokenTo",
"value": "header",
"type": "string"
}
]
},
"method": "PATCH",
"header": [
{
"key": "Content-type",
"value": "application/json",
"type": "text"
},
{
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
"key": "Authorization",
"value": "Bearer <Token>",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "\r\n{\r\n \"givenName\": \"sam\",\r\n \"jobTitle\": \"Dynamics Architect\",\r\n \"mobilePhone\": \"9988776600\",\r\n \"officeLocation\": \"India\",\r\n \"preferredLanguage\": \"en-us\",\r\n \"surname\": \"Khan\"\r\n}\r\n\r\n\r\n"
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/users/57e64c5f-cf09-4b85-be69-a589057d4a34",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"users",
"57e64c5f-cf09-4b85-be69-a589057d4a34"
]
}
},
"response": []
}
Update Password:
{
"name": "Update password",
"request": {
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "addTokenTo",
"value": "header",
"type": "string"
}
]
},
"method": "PATCH",
"header": [
{
"key": "Content-type",
"value": "application/json",
"type": "text"
},
{
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
"key": "Authorization",
"value": "Bearer <Token>",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": " {\r\n \"passwordProfile\": {\r\n \"forceChangePasswordNextSignIn\": false,\r\n \"password\": \"mQht3Wthnj2\"\r\n }\r\n }"
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/users/57e64c5f-cf09-4b85-be69-a589057d4a34",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"users",
"57e64c5f-cf09-4b85-be69-a589057d4a34"
]
}
},
"response": []
}
Get License:
{
"name": "Get license",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "addTokenTo",
"value": "header",
"type": "string"
}
]
},
"method": "GET",
"header": [
{
"key": "Content-type",
"value": "application/json",
"type": "text"
},
{
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
"key": "Authorization",
"value": "Bearer <Token>",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/a4cb01c0-f5d2-4787-8cbf-9726cdd8466c/subscribedSkus",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"a4cb01c0-f5d2-4787-8cbf-9726cdd8466c",
"subscribedSkus"
]
}
},
"response": []
}
Assign License:
{
"name": "assign license",
"request": {
"auth": {
"type": "oauth2",
"oauth2": [
{
"key": "addTokenTo",
"value": "header",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-type",
"value": "application/json",
"type": "text"
},
{
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
"key": "Authorization",
"value": "Bearer <Token>",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"addLicenses\": [\r\n {\r\n \"disabledPlans\": [ ],\r\n \"skuId\": \"4b9405b0-7788-4568-add1-99614e613b69\"\r\n }\r\n ],\r\n \"removeLicenses\": [ ]\r\n}"
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/users/a4cb01c0-f5d2-4787-8cbf-9726cdd8466c/assignLicense",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"users",
"a4cb01c0-f5d2-4787-8cbf-9726cdd8466c",
"assignLicense"
]
}
},
"response": []
}
Enable-Disable User Account:
{
"name": "Enable-Disable User Account",
"request": {
"method": "PATCH",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "Authorization",
"value": "Bearer <Token>",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"accountEnabled\": true\r\n}",
"options": {
"raw": {
"language": "javascript"
}
}
},
"url": {
"raw": "https://graph.microsoft.com/v1.0/users/655f60c8-66db-4c7c-a87b-76680e7f89a7",
"protocol": "https",
"host": [
"graph",
"microsoft",
"com"
],
"path": [
"v1.0",
"users",
"655f60c8-66db-4c7c-a87b-76680e7f89a7"
]
}
},
"response": []
}
Thanks for reading the article. Hope this Article will helpful for you. Cheers!!!