{"id":2054,"date":"2018-11-11T11:00:30","date_gmt":"2018-11-11T11:00:30","guid":{"rendered":"https:\/\/developer.microsoft.com\/en-us\/office\/blogs\/?p=2054"},"modified":"2018-11-11T11:00:30","modified_gmt":"2018-11-11T11:00:30","slug":"30daysmsgraph-day-11-azure-ad-application-permissions","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/30daysmsgraph-day-11-azure-ad-application-permissions\/","title":{"rendered":"30DaysMSGraph \u2013 Day 11 \u2013 Azure AD application permissions"},"content":{"rendered":"<p><a href=\"https:\/\/aka.ms\/30DaysMSGraph\">List of all posts in the #30DaysMSGraph series<\/a><\/p>\n<p>In <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/30daysmsgraph-day-10-azure-ad-applications-on-v1-endpoint\">Day 10<\/a> we discussed Azure AD applications created through the V1 endpoint.\u00a0 Today we&#8217;ll look at the permissions available and how to assign them to a user \/ Azure AD application.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-2089\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/30DaysMSGraph_Day11_Source-1024x576.jpg\" alt=\"\" width=\"800\" height=\"450\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/30DaysMSGraph_Day11_Source-1024x576.jpg 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/30DaysMSGraph_Day11_Source-300x169.jpg 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/30DaysMSGraph_Day11_Source-768x432.jpg 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/30DaysMSGraph_Day11_Source.jpg 1280w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<h2>Types of permissions<\/h2>\n<p>Accessing Microsoft Graph endpoints requires that the application and \/ or user making the request has the appropriate permissions assigned.\u00a0 These permissions can be one of two types: <strong>delegated permissions<\/strong> or <strong>application permissions<\/strong>.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-2091\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day11-AADPermissions1-1024x425.png\" alt=\"\" width=\"800\" height=\"332\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day11-AADPermissions1-1024x425.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day11-AADPermissions1-300x125.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day11-AADPermissions1-768x319.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day11-AADPermissions1.png 1207w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<h3>Delegated (on behalf of)<\/h3>\n<p>Delegated permissions, sometimes called &#8220;on behalf of&#8221; permissions, require a user context to also be supplied when making the request.\u00a0 In effect an application is making Microsoft Graph requests on behalf of the user.\u00a0 As such, the required permissions will be a combination of 1) what the user has permissions to do and 2) what the application has permissions to do.<\/p>\n<p>The logical intersection of these two results in the <u>effective permissions<\/u> used when making requests.\u00a0 If the application has been granted permissions (ex. read all user info from Azure AD) that the user has not been granted, then the application will not be able to complete that specific request.<\/p>\n<p>If you are decoding an access token (see <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/30daysmsgraph-day-8-authentication-roadmap-and-access-tokens\">Day 8<\/a>), delegated permissions will show up as &#8220;scopes&#8221; within the decoded claims.\u00a0 Checking that the access token has the appropriate \/ expected &#8220;scopes&#8221; is a good first step to ensure that permissions are assigned and consented.<\/p>\n<p>&nbsp;<\/p>\n<h3>Application (app-only or &#8220;without a user&#8221;)<\/h3>\n<p>Application permissions, sometimes called app-only or &#8220;without a user&#8221;, run without a user context.\u00a0 Common examples of this would be a background service or a daemon application.\u00a0 Only the permissions granted to the application will be evaluated when Microsoft Graph request is made.<\/p>\n<p>Typically an Azure AD domain administrator needs to grant consent for the application permissions requested.\u00a0 However, there is a new Azure AD role called Application Administrator that is able to consent to delegated permissions for Azure AD apps, and applications permissions excluding Microsoft Graph and Azure AD Graph.\u00a0 For the purposes of this blog series that may not be suitable given the Microsoft Graph exclusion but it is worth noting for other scenarios.\u00a0 Read more about available roles\u00a0for <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/active-directory\/users-groups-roles\/directory-assign-admin-roles#available-roles\">Administrator role permissions in Azure Active Directory<\/a>.<\/p>\n<p>If you are decoding an access token (see <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/30daysmsgraph-day-8-authentication-roadmap-and-access-tokens\">Day 8<\/a>), application permissions will show up as &#8220;roles&#8221; within the decoded claims.\u00a0 Checking that the access token has the appropriate \/ expected &#8220;roles&#8221; is a good first step to ensure that permissions are assigned and consented.<\/p>\n<p>&nbsp;<\/p>\n<h3>Permission naming pattern<\/h3>\n<p>All permissions within Microsoft Graph have an internal name that follows a specific pattern:<\/p>\n<ul>\n<li>Resource.Operation.Constraint<\/li>\n<\/ul>\n<p>Ex. <em>User.Read.All <\/em>= <u>Read<\/u> permission for <u>all<\/u> <u>users<\/u> in the current directory.<\/p>\n<p>The resource and operation will always be specified, but the constraint is optional and defines the potential scope within the service \/ directory.\u00a0 If the constraint is not listed, then the permission applies to the resources for the currently logged in user.<\/p>\n<p>Ex. <em>User.Read<\/em> = <u>Read<\/u> permission for the currently logged in <u>user<\/u>.<\/p>\n<p>For a full listing of all permissions grouped by resource please refer to the <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/docs\/concepts\/permissions_reference\">Microsoft Graph permissions reference<\/a>.\u00a0 See the following screenshot for an example of the permissions required for a given operation on the Microsoft Graph.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-2090\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day11-Permissions1.png\" alt=\"\" width=\"800\" height=\"276\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day11-Permissions1.png 865w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day11-Permissions1-300x103.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2018\/11\/Day11-Permissions1-768x265.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p><em><strong>Note<\/strong>: Permissions required are listed from least privileged to most privileged.\u00a0 In general it is a best practice to request \/ consent the least privilege necessary to accomplish a task.\u00a0 Ex. User.Read is preferred to User.ReadWrite.\u00a0 If, however, the application needs both User.Read and User.ReadWrite then both could be satisfied with User.ReadWrite alone.<\/em><\/p>\n<p>&nbsp;<\/p>\n<h2>Try It Out<\/h2>\n<p>Navigate to the <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/docs\/concepts\/v1-overview\">Microsoft Graph API reference<\/a>.<\/p>\n<p><a href=\"https:\/\/github.com\/microsoftgraph\/30DaysMSGraph-TryItOut\/blob\/master\/Day11-AppPermissions.md\">Day 11 repo link<\/a><\/p>\n<ol>\n<li>Find an operation that you would like to complete and identify the permissions required for that operation.\n<ul>\n<li>Ex. <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/docs\/api-reference\/v1.0\/api\/user_post_users\">Users \u2013 Create User<\/a><\/li>\n<li>Ex. <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/docs\/api-reference\/v1.0\/api\/user_list_messages\">Mail &#8211; List Messages<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>Join us tomorrow as we look at authentication flows for Microsoft Graph requests in <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/30daysmsgraph-day-12-authentication-and-authorization-scenarios\">Day 12<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Day 10 we discussed Azure AD applications created through the V1 endpoint.\u00a0 Today we&#8217;ll look at the permissions available and how to assign them to a user \/ Azure AD application.<\/p>\n","protected":false},"author":73055,"featured_media":25159,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[84],"class_list":["post-2054","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-graph","tag-30daysmsgraph"],"acf":[],"blog_post_summary":"<p>In Day 10 we discussed Azure AD applications created through the V1 endpoint.\u00a0 Today we&#8217;ll look at the permissions available and how to assign them to a user \/ Azure AD application.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/2054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/73055"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=2054"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/2054\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/25159"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=2054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=2054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=2054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}