Forum Discussion

Prakash_Singh's avatar
Prakash_Singh
Brass Contributor
Apr 25, 2024

Enterprise application app secrete key need to update for SharePoint Online access.

Hi,

I need to update the app secrete key which is already expired so that client can access SharePoint online site with app id and key.

Problem is that this app I can only see under "Enterprise application" in "Azure AD" as "Service Principle" where I am not getting any option to update the secret key.

And this app not showing under "App Registration" in "Azure AD".

 

How to update the secret key via GUI or PowerShell command.

Need help.

 

  • I found the PowerShell Command:
    $app = Get-AzureADServicePrincipal -objectID ""
    #Get the Current Expiry Date
    $CurrentExpiryDate = (Get-AzureADServicePrincipalPasswordCredential -ObjectId $App.ObjectId).EndDate

    #Extend the validity of the App by 1 years
    $StartDate = Get-Date
    $EndDate = $StartDate.AddYears(1)
    New-AzureADServicePrincipalPasswordCredential -ObjectId $App.ObjectId -StartDate $StartDate -EndDate $EndDate
  • Prakash_Singh 

    If the app secret key has expired, and you can’t find the application under "App Registration" in Azure AD, you might have to take an indirect approach to update the secret key. Here’s what you can do:

    1. Check Enterprise Applications: In Azure AD, under "Enterprise Applications", locate the application representing your SharePoint Online access. If you find it there, note down the Application ID.

    2. Use PowerShell to Regenerate Secret:

      • Ensure you have the AzureAD PowerShell module installed. If not, install it with:
        powershell
         
        Install-Module -Name AzureAD
      • Connect to Azure AD with appropriate permissions:
        powershell
        Connect-AzureAD
      • Use the Application ID to create a new secret key for the Service Principal:
        powershell
        New-AzureADServicePrincipalPasswordCredential -ObjectId <Application ID> -StartDate <Start Date> -EndDate <End Date>
      • This command will generate a new secret key. Make sure to note it down, as it will not be displayed again.
    3. Update Client with New Secret Key:

      • Once you've generated the new secret key, update the client application with the new key so that it n access SharePoint Online.
    4. Revise Application Setup:

      • If possible, locate the original application in "App Registrations" in Azure AD for future management. If you can’t find it, consider re-registering the app to have better control over its configurations and secret keys.  Visit Here
  • Prakash_Singh 

     

    Try locate from below:

     

    1. Login to the Azure AD Portal → Azure Active Directory → App Registrations

    2. Choose All Applications and search for your application

    3. Use either the application name or your client ID while searching for your application on the portal

    4. Click on your application to enter the Overview page

  • Prakash_Singh's avatar
    Prakash_Singh
    Brass Contributor
    I found the PowerShell Command:
    $app = Get-AzureADServicePrincipal -objectID ""
    #Get the Current Expiry Date
    $CurrentExpiryDate = (Get-AzureADServicePrincipalPasswordCredential -ObjectId $App.ObjectId).EndDate

    #Extend the validity of the App by 1 years
    $StartDate = Get-Date
    $EndDate = $StartDate.AddYears(1)
    New-AzureADServicePrincipalPasswordCredential -ObjectId $App.ObjectId -StartDate $StartDate -EndDate $EndDate

Resources