Skip to content
English
  • There are no suggestions because the search field is empty.

Office 365 - change app registration secret

Office 365 - change app registration secret Question : What are the steps to follow -- KA-01491

Question: What are the steps to follow to renew the app-secret for the Mavim app

Answer:
Updating the client secret with PowerShell can be done for app registrations created in SharePoint or in Azure AD using the Azure portal.

(This documentation is based on the following Microsoft documentation: https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/replace-an-expiring-client-secret-in-a-sharepoint-add-in)

Connect to MSOnline via the SharePoint Windows PowerShell with the tenant admin user:

import-module MSOnline
connect-msolservice


If you are using a tenant administrator account that has permissions to multiple tenants; you must set the parameter "-TenantId <Guid>" for all subsequent commands in steps 2-4. (See the official Microsoft documentation for more information)

Obtain Service Principals and keys. Printing $keys produces three records. You also see the end date of each key. Check if your expired key is shown.

$clientId = "dee98b74-62dc-400e-96b3-73e345cfc91e"
$keys = Get-MsolServicePrincipalCredential -AppPrincipalId $clientId -ReturnKeyValues $true
$keys


Generate a new Client Secret for this client ID. The same client ID as set in the previous step is used. The new Client Secret is valid for one year.

$bytes = New-Object Byte[] 32
$rand = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$rand.GetBytes($bytes)
$rand.Dispose()
$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 $dtEnd
New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Symmetric -Usage Verify
             -Value $newClientSecret -StartDate $dtStart -EndDate $dtEnd
New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Password -Usage Verify
             -Value $newClientSecret -StartDate $dtStart -EndDate $dtEnd
$newClientSecret


Make sure you update the Mavim Portal Office 365 configuration settings by logging into the Portal as Admin and going to the Office 365 tab via the dashboard button.

A screenshot of a computer<br><br>Description automatically generated