Thursday, February 7, 2013

SharePoint 2013 Provider-hosted Apps: The specified application identifier is invalid or does not exist

Scenario: When you are trying to install Provider-hosted  .app package provided by third party Or when moving your app package from Development machine to Test or Production machine and trying to install your app. You may hit below error message, as I have today :-
The specified application identifier cbd25585-947e-4b9d-8686-ed695101ed9a is invalid or does not exist.

Resolution1: Run all of the below commands in SharePoint 2013 management shell:-

$publicCertPath = "C:\AppCerts\HighTrustSampleCert.cer"
$appId = "cbd25585-947e-4b9d-8686-ed695101ed9a"
$spurl ="https://mycompany.com/"
$spweb = Get-SPWeb $spurl
$realm = Get-SPAuthenticationRealm -ServiceContext $spweb.Site
$certificate = Get-PfxCertificate $publicCertPath
$fullAppIdentifier = $appId + '@' + $realm
New-SPTrustedSecurityTokenIssuer -Name "TheaterCompany" -Certificate $certificate -RegisteredIssuerName $fullAppIdentifier
$appPrincipal = Register-SPAppPrincipal -NameIdentifier $fullAppIdentifier -Site $spweb -DisplayName "TheaterCompany"
Set-SPAppPrincipalPermission -Site $spweb -AppPrincipal $appPrincipal -Scope Site -Right FullControl

Note: Before running the above commands,replace the $appId with the ID reported in the error message. Also modify other variables like $spurl  etc. as per your environment.

Resolution2 (Recommended): To get away with the above error message. Create a ClientID and ClientSecret using "_layouts/15/appregnew.aspx" page. Basically, you need to register your app on the target SharePoint farm where you intend to deploy your app. And then use those generated ClientID and ClientSecret while packaging your app in your dev environment.

1 comment: