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
+20-26Lines changed: 20 additions & 26 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: 06/21/2023
4
+
ms.date: 09/13/2023
5
5
ms.localizationpriority: high
6
6
ms.service: sharepoint
7
7
---
@@ -25,8 +25,8 @@ Removing an expired secret from ACS before you remove it from the application co
25
25
26
26
Ensure the following before you begin:
27
27
28
-
- You have installed Microsoft Graph Powershell SDK: [Install the Microsoft Graph PowerShell SDK](/powershell/microsoftgraph/installation)
29
-
- 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.
28
+
- You have installed Azure Active Directory PowerShell 2.0: [Install Azure Active Directory PowerShell for Graph](/powershell/azure/active-directory/install-adv2)
29
+
- You're a tenant administrator for the Microsoft 365 tenant where the add-in was registered with the **AppRegNew.aspx** page.
30
30
31
31
## Generate a new secret
32
32
@@ -35,42 +35,36 @@ Ensure the following before you begin:
35
35
```powershell
36
36
$clientId = 'client id of the add-in'
37
37
```
38
-
1. Connect to graph with **Application.ReadWrite.All** scope:
1. The new client secret appears on the Windows PowerShell console. Copy it to a text file. You use it in the next procedure.
63
62
64
63
> [!TIP]
65
-
> 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.
64
+
> By default, the secret lasts one year. You can customize by leveraging the example below to specify the EndDateTime.
66
65
>
67
66
> ``` powershell
68
-
> $params = @{
69
-
> PasswordCredential = @{
70
-
> DisplayName = "NewSecret" # Replace with a firendly name.
71
-
> EndDateTime = "2025-01-01T00:00:00Z" # Optional. Specify the end date you want. Using ISO 8601 format.
72
-
> }
73
-
> }
67
+
> $endDate = (Get-Date).AddYears(2) # 2 year.
74
68
> ```
75
69
76
70
## Update the remote web application in Visual Studio to use the new secret
@@ -80,7 +74,7 @@ Ensure the following before you begin:
80
74
81
75
1. Open the SharePoint Add-in project in Visual Studio, and open the **web.config** file for the web application project. In the `appSettings` section, there are keys for the client ID and client secret. The following is an example:
82
76
83
-
```XML
77
+
```xml
84
78
<appSettings>
85
79
<add key="ClientId" value="your client id here" />
86
80
<add key="ClientSecret" value="your old secret here" />
@@ -90,7 +84,7 @@ Ensure the following before you begin:
90
84
91
85
1. Change the name of the `ClientSecret` key to `SecondaryClientSecret` as shown in the following example:
92
86
93
-
```XML
87
+
```xml
94
88
<add key="SecondaryClientSecret" value="your old secret here" />
95
89
```
96
90
@@ -99,7 +93,7 @@ Ensure the following before you begin:
99
93
100
94
1. Add a new `ClientSecret` key and give it your new client secret. Your markup should now look like the following:
101
95
102
-
```XML
96
+
```xml
103
97
<appSettings>
104
98
<add key="ClientId" value="your client id here" />
105
99
<add key="ClientSecret" value="your new secret here" />
0 commit comments