Renewing SharePoint Online Provider add-ins client secret

Jun 16, 2017 · 4 min read
Image for post
Image for post
Figure 1 — Renewing SharePoint Add-ins client secret article mind map.



When is the end date?

Connect-MsolService$clientID = “d65cdd2b-9e19–4076–901f-9f9031080339”Get-MsolServicePrincipal -AppPrincipalId $clientIDGet-MsolServicePrincipalCredential -AppPrincipalId $clientID -ReturnKeyValues $false | Where-Object { ($_.Type -ne “Other”) -and ($_.Type -ne “Asymmetric”) }
Image for post
Image for post
Figure 2 — Results of querying SharePoint Online add-in keys expiration end date.

Creating a new secret

## Step 1
# Get keys
Connect-MsolService$clientID = “9825a06f-61de-461d-9efa-a28a9c3b1917” # Update to application client IDGet-MsolServicePrincipal -AppPrincipalId $clientID$keys = Get-MsolServicePrincipalCredential -AppPrincipalId $clientID -ReturnKeyValues $true$keys
## Step 2
# Remove keys
Remove-MsolServicePrincipalCredential -KeyIds @(“KeyID1”,”KeyID2",”KeyID3") -AppPrincipalId $clientID
## Step 3 — Recommended to wait 24 hours before creating new keys
# Create new keys for three years
$bytes = New-Object Byte[] 32
$rand = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$newClientSecret = [System.Convert]::ToBase64String($bytes)
$dtStart = [System.DateTime]::Now
$dtEnd = $dtStart.AddYears(3)
New-MsolServicePrincipalCredential -AppPrincipalId $clientID -Type Symmetric -Usage Sign -Value $newClientSecret -StartDate $dtStart -EndDate $dtEndNew-MsolServicePrincipalCredential -AppPrincipalId $clientID -Type Symmetric -Usage Verify -Value $newClientSecret -StartDate $dtStart -EndDate $dtEndNew-MsolServicePrincipalCredential -AppPrincipalId $clientID -Type Password -Usage Verify -Value $newClientSecret -StartDate $dtStart -EndDate $dtEnd$newClientSecret
## Step 4
# Confirm new end dates
Get-MsolServicePrincipal -AppPrincipalId $clientID$keys = Get-MsolServicePrincipalCredential -AppPrincipalId $clientID -ReturnKeyValues $true$keys


Extra resources

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store