5

I need to register a Provider hosted app in a site collection. It is possible to do it manually by using appregnew.aspx page. Is there anyway to do the same using C#/Powershell?

3

I fixed it myself. You can register the app in office 365 tenancy[SharePoint Online] using the below Azure AD MSOLService PS Script.

$clientID="7c6cbd92-073b-4bc9-9d4a-fc27749f340b";
$newClientSecret = "p/zEuKBqkZRQsz6yRpOafj2f6zZdnQYvONatGWj0N0M=";
$appDomain="Yourdomain.azurewebsites.net";
$appUrl="https://Yourdomain.azurewebsites.net/";
$appName="Your App Name"
$servicePrincipalName = @("$clientID/$appDomain")
$dtStart = [System.DateTime]::Now
$dtEnd = $dtStart.AddYears(10)

Connect-MsolService 
New-MsolServicePrincipal -ServicePrincipalNames $servicePrincipalName -AppPrincipalId $clientID -DisplayName $appName -Type Symmetric -Usage Verify -Value $newClientSecret -Addresses (New-MsolServicePrincipalAddresses -Address $appUrl) -StartDate $dtStart  –EndDate $dtEnd
New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Symmetric -Usage Sign -Value $newClientSecret -StartDate $dtStart  –EndDate $dtEnd
New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Password -Usage Verify -Value $newClientSecret -StartDate $dtStart  –EndDate $dtEnd
  • Hi, is there any way to do this in C#/CSOM? – Naveen Prasath Oct 10 '18 at 14:58
  • There is no such option to do this using CSOM. Also, this does not come under SharePoint this is related to Azure AD. – Arut Oct 11 '18 at 9:17
  • ok. Thanks. But it will create a new app principal in SharePoint Online right? – Naveen Prasath Oct 11 '18 at 10:13
  • 1
    Yes, it will create new app principal in SharePoint online as it is bonded to Azure AD. – Arut Oct 11 '18 at 10:27
2

Please read this link: Register SharePoint Add-ins

According to this link you can also Register the add-in through the Seller Dashboard. It's great option if you're going to use your add-in in more than one SharePoint tenant or farm. Publication in store is not required. This way you can choose a three-year valid secret key.

1

No, there is not, because the manual granting of consent is part of the app model architecture.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.