You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sp-add-ins/replace-an-expiring-client-secret-in-a-sharepoint-add-in.md
+45-20Lines changed: 45 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Replace an expiring client secret in a SharePoint Add-in
3
3
description: Add a new client secret for a SharePoint Add-in that is registered with AppRegNew.aspx.
4
-
ms.date: 09/26/2023
4
+
ms.date: 09/09/2024
5
5
ms.localizationpriority: high
6
6
ms.service: sharepoint
7
7
---
@@ -27,8 +27,8 @@ Removing an expired secret from ACS before you remove it from the application co
27
27
28
28
Ensure the following before you begin:
29
29
30
-
- You have installed Azure Active Directory PowerShell 2.0: [Install Azure Active Directory PowerShell for Graph](/powershell/azure/active-directory/install-adv2)
31
-
- You're a tenant administrator for the Microsoft 365 tenant where the add-in was registered with the **AppRegNew.aspx** page.
30
+
- You have installed Microsoft Graph Powershell SDK: [Install the Microsoft Graph PowerShell SDK](/powershell/microsoftgraph/installation)
31
+
- You're a tenant administrator (or having `Application.ReadWrite.All` permission) for the Microsoft 365 tenant where the add-in was registered with the **AppRegNew.aspx** page.
32
32
33
33
## Generate a new secret
34
34
@@ -38,35 +38,60 @@ Ensure the following before you begin:
38
38
$clientId = 'client id of the add-in'
39
39
```
40
40
41
-
1. Connect to AzureAD PowerShell.
41
+
2. Connect to graph with `Application.ReadWrite.All, Directory.ReadWrite.All` scope.
42
42
43
43
```powershell
44
-
$AzureAdCred = Get-Credential
45
-
Connect-AzureAD -Credential $AzureAdCred # Login to AzureAD
44
+
Connect-MgGraph -Scopes "Application.ReadWrite.All,Directory.ReadWrite.All" # Login with corresponding scope. Should be tenant admin or anyone have the permission.
46
45
```
47
46
48
-
1. Generate a new client secret with the following lines:
47
+
3. Generate a new client secret with the following lines:
1. The new client secret appears on the Windows PowerShell console. Copy it to a text file. You use it in the next procedure.
83
+
4. The new client secret appears on the Windows PowerShell console. Copy it to a text file. You use it in the next procedure.
64
84
65
85
> [!TIP]
66
-
> By default, the secret lasts one year. You can customize by leveraging the example below to specify the EndDateTime.
86
+
> By default, the secret lasts two years if you didn't specify the EndDateTime. You can customize by leveraging the example below to specify the EndDateTime.
67
87
>
68
88
> ``` powershell
69
-
> $endDate = (Get-Date).AddYears(2) # 2 year.
89
+
> $params = @{
90
+
> PasswordCredential = @{
91
+
> DisplayName = "NewSecret" # Replace with a firendly name.
92
+
> EndDateTime = "2025-01-01T00:00:00Z" # Optional. Specify the end date you want. Using ISO 8601 format.
93
+
> }
94
+
> }
70
95
> ```
71
96
72
97
## Update the remote web application in Visual Studio to use the new secret
0 commit comments