On Premises

Generate a new client secret for SharePoint Template

Prerequisites

Make sure the following prerequisites are met

  1. User is SharePoint Online global administrators and tenant administrator for the Microsoft 365 tenant

  2. Install SharePoint Online Management Shell

    https://www.microsoft.com/en-us/download/details.aspx?id=35588

  3. Install PowerShell PowerShellGet

    1. Open PowerShell as administrator

    2. Run:

      Copy
      PowerShell
      Install-Module –Name PowerShellGet –Force
      Update-Module -Name PowerShellGet
  4. Install "Microsoft Online Services"

    1. Open PowerShell as administrator

    2. Run:

      Copy
      PowerShell
      Install-Module -Name MSOnline

Generate

Note: Generating a new secret won’t affect to old one, the current Client Secret will be active until it expires

Note: If the client secret is already expired, creating a new app is recommended: UCC Creator - Install Manual “Register SharePoint App (only for SharePoint Online)”

  1. Run Powershell as administrator

  2. Run the following cmdlets: (Change the client id value to your client id)

    Copy
    PowerShell
    Connect-MsolService
    $clientId = 'clientid'
    $bytes = New-Object Byte[] 32
    $rand = [System.Security.Cryptography.RandomNumberGenerator]::Create()
    $rand.GetBytes($bytes)
    $rand.Dispose()
    $newClientSecret = [System.Convert]::ToBase64String($bytes)
    New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Symmetric -Usage Sign -Value $newClientSecret
    New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Symmetric -Usage Verify -Value $newClientSecret
    New-MsolServicePrincipalCredential -AppPrincipalId $clientId -Type Password -Usage Verify -Value $newClientSecret
    $newClientSecret
  3. Copy outcome and save it