Search This Blog

Thursday, April 13, 2017

Provider Hosted Apps in SharePoint 2013

Create Certificate (Cer):
Go to IIS
Click on server certificates
Next click on the right pane select the self-signed certificate and give the name: TrustedCertificate then
Click on OK
Export Certificate (pfx):
In IIS Click on the certificate next click on the export then select location and give password
Copy Certificate (Cer):
In IIS double click the certificate next select details tab click on CopytoFile
Next click on next button select the No do not export the private key
Next click on next button select the DER encoded binary
Next click on next button choose the file where you want save
Next click on finish button
Run the below PowerShell command:
$cert=Get-PfxCertificate -FilePath "C:\Certs\TrustedCertificate.cer"
 $issuerid=[System.Guid]::NewGuid().ToString() // 35f57afc-2895-4825-9c60-bc37a91e2a51
 $realmid=Get-SPAuthenticationRealm -ServiceContext "http://SPSite:41127/sites/DeveloperSite/"
$registeredName=$issuerid + "@" + $realmid
New-SPTrustedSecurityTokenIssuer -Name "DevelopmentApp" -RegisteredIssuerName $registeredName -IsTrustBroker -Certificate $cert
$issuerId will give the Issuer id
$realmid will give the real Id
$registeredName will give the registered name.
Go to Visual studio:
Select the App for SharePoint the app name: PagesCreationUsingPageViewerWebpart click on OK.
Next give developer site URL and select provider hosted
Click on next select the ASP.NET web forms Application
Click on next select use certificate and give the below details: pfx certificate location, password and realmid
Check in Web.config is done properly or not.
Step 9:Run the project in visual studio and check whether client Id is generated or not in web.config.
Step 10:Change the Permission in AppManifest.xml
Step 12:Run the below script  for generating APP ID
$clientid = " bded8c2e-da2d-4c2a-a8c3-0dbcf3e42f8e"
 $appId = $clientid + "@" + $realmid
 Register-SPAppPrincipal -Site "http://SPSite:41127/sites/DeveloperSite/"  -NameIdentifier $appId
Step 13:Run the below script
$config = (Get-SPSecurityTokenServiceConfig)
$config.AllowOAuthOverHttp = $true
Step 14 : Deploy it finally.

No comments:

Post a Comment