{"id":42,"date":"2023-07-16T13:47:00","date_gmt":"2023-07-16T13:47:00","guid":{"rendered":"https:\/\/kb.ctse.nl\/?page_id=42"},"modified":"2024-01-20T23:28:27","modified_gmt":"2024-01-20T23:28:27","slug":"powerdoc-installation-create-2-appregistrations","status":"publish","type":"page","link":"https:\/\/kb.ctse.nl\/?page_id=42","title":{"rendered":"PowerDoc Installation: AppRegistration"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>Azure App registration<\/strong><\/h2>\n\n\n\n<p>1) In the Azure-portal create a new appregistration<\/p>\n\n\n\n<p>Name: PowerDoc<\/p>\n\n\n\n<p>Platform: SPA (single page application)<\/p>\n\n\n\n<p>Redirect-url: set here the url of the PowerApps-environment, for example: https:\/\/contoso.crm4.dynamics.com<\/p>\n\n\n\n<p>Api-permissions:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Api<\/strong><\/td><td><strong>Type<\/strong><\/td><td><strong>Permission<\/strong><\/td><\/tr><tr><td rowspan=\"4\">Microsoft Graph<\/td><td rowspan=\"3\">Delegated<\/td><td>Files.ReadWrite.All<\/td><\/tr><tr><td>Sites.Read.All<\/td><\/tr><tr><td>User.Read<\/td><\/tr><tr><td>Application<\/td><td>Sites.Selected<\/td><\/tr><tr><td rowspan=\"2\">Power Automate<\/td><td rowspan=\"2\">Delegated<\/td><td>Flows.Read.All<\/td><\/tr><tr><td>User<\/td><\/tr><tr><td>PowerApps Service<\/td><td>Delegated<\/td><td>User<\/td><\/tr><tr><td>Sharepoint<\/td><td>Application<\/td><td>Sites.Selected<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>NB: after adding the permissions, click on the button &#8220;Grant admin consent for&#8230;&#8221;<\/p>\n\n\n\n<p><p>2) Under \u201cAuthentication\u201d you can set more redirect-urls for the other environments, for example:<\/p>\n<p>https:\/\/contoso-dev.crm4.dynamics.com<br>\nhttps:\/\/contoso-acc.crm4.dynamics.com<br>\nhttps:\/\/contoso.crm4.dynamics.com<\/p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>NB: Don\u2019t forget to save when you\u2019re done!<\/p>\n\n\n\n<p>3) Collect the client-id of the appregistration, you can find this in the appregistration at \u201cOverview\u201d and then the value of \u201cApplication (client) ID\u201d.<\/p>\n\n\n\n<p>4) Secret: create a never ending secret by this PowerShell-command (replace xxxx-xxxx-xxxx-xxxx-xxxx by the <em><u>object-id<\/u><\/em> of the appregistration):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Install-Module AzureAD -Force\nConnect-AzureAD\n$appObjectId = \"xxxx-xxxx-xxxx-xxxx-xxxx\"\n$startDate = Get-Date\n$endDate = $startDate.AddYears(98)\n$aadAppsecret01 = New-AzureADApplicationPasswordCredential -ObjectId $appObjectId -StartDate $startDate -EndDate $endDate\nWrite-Output $aadAppsecret01<\/code><\/pre>\n\n\n\n<p>NB: Collect the generated secret from the output.<\/p>\n\n\n\n<p>5) Set site-permissions for app via PowerShell (replace {host} and {sitename} by valid values and replace the yyyy-yyyy-yyyy-yyyy-yyyy value by the <em><u>client-id<\/u><\/em> of the appregistration):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Install-Module -Name PnP.PowerShell\n$siteUrl=\"https:\/\/{host}.sharepoint.com\/sites\/{sitename}\"\n$clientId=\"yyyy-yyyy-yyyy-yyyy-yyyy\"\n$appName=\"PowerDocs S2S\"\nConnect-PnPOnline $siteUrl -Interactive\nGrant-PnPAzureADAppSitePermission -AppId $clientId -DisplayName $appName -Site $siteUrl -Permissions Write\nSet-PnPTenant -DisableCustomAppAuthentication $false<\/code><\/pre>\n\n\n\n<p>6) After this go in your browser to this address (replace {host} and {sitename} by valid values):<\/p>\n\n\n\n<p>App-Id: search on the <em><u>client-id<\/u><\/em> of the appregistration<\/p>\n\n\n\n<p>Title: will be filled automatically<\/p>\n\n\n\n<p>App-domain: localhost<\/p>\n\n\n\n<p>Redirect-url: https:\/\/localhost<\/p>\n\n\n\n<p>Xml:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;AppPermissionRequests AllowAppOnlyPolicy=\"true\"&gt;\n&nbsp; &lt;AppPermissionRequest Scope=\"http:\/\/sharepoint\/content\/sitecollection\" Right=\"FullControl\" \/&gt;\n&lt;\/AppPermissionRequests&gt;<\/code><\/pre>\n\n\n\n<p>Click on the button \u201cCreate\u201d and after that on the button \u201cTrust it\u201d.<\/p>\n\n\n\n<p><a href=\"https:\/\/kb.ctse.nl\/?page_id=45\" data-type=\"page\" data-id=\"45\">Go to next step &gt;<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Azure App registration 1) In the Azure-portal create a new appregistration Name: PowerDoc Platform: SPA (single page application) Redirect-url: set here the url of the PowerApps-environment, for example: https:\/\/contoso.crm4.dynamics.com Api-permissions: Api Type Permission Microsoft Graph Delegated Files.ReadWrite.All Sites.Read.All User.Read Application Sites.Selected Power Automate Delegated Flows.Read.All User PowerApps Service Delegated User Sharepoint Application Sites.Selected NB: after [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":38,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-42","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/kb.ctse.nl\/index.php?rest_route=\/wp\/v2\/pages\/42","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.ctse.nl\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/kb.ctse.nl\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/kb.ctse.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.ctse.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=42"}],"version-history":[{"count":16,"href":"https:\/\/kb.ctse.nl\/index.php?rest_route=\/wp\/v2\/pages\/42\/revisions"}],"predecessor-version":[{"id":304,"href":"https:\/\/kb.ctse.nl\/index.php?rest_route=\/wp\/v2\/pages\/42\/revisions\/304"}],"up":[{"embeddable":true,"href":"https:\/\/kb.ctse.nl\/index.php?rest_route=\/wp\/v2\/pages\/38"}],"wp:attachment":[{"href":"https:\/\/kb.ctse.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}