refactor: Replace client secret auth with interactive authentication
This commit is contained in:
parent
21bc01e3cc
commit
61be5f9256
@ -74,9 +74,7 @@ $btnSaveConfig.Text = "Save Config"
|
||||
$btnSaveConfig.Add_Click({
|
||||
Save-Config -SiteUrl $txtSiteUrl.Text `
|
||||
-ProductionLibrary $txtProdLib.Text `
|
||||
-TempLibrary $txtTempLib.Text `
|
||||
-ClientId $config.ClientId `
|
||||
-ClientSecret $config.ClientSecret
|
||||
-TempLibrary $txtTempLib.Text
|
||||
})
|
||||
|
||||
$form.Controls.AddRange(@(
|
||||
|
||||
@ -19,17 +19,13 @@ function Save-Config {
|
||||
param(
|
||||
[string]$SiteUrl,
|
||||
[string]$ProductionLibrary,
|
||||
[string]$TempLibrary,
|
||||
[string]$ClientId,
|
||||
[string]$ClientSecret
|
||||
[string]$TempLibrary
|
||||
)
|
||||
|
||||
$config = @{
|
||||
SiteUrl = $SiteUrl
|
||||
ProductionLibrary = $ProductionLibrary
|
||||
TempLibrary = $TempLibrary
|
||||
ClientId = $ClientId
|
||||
ClientSecret = $ClientSecret
|
||||
}
|
||||
|
||||
$config | ConvertTo-Json | Set-Content $configPath
|
||||
@ -38,17 +34,16 @@ function Save-Config {
|
||||
function Connect-SharePoint {
|
||||
try {
|
||||
$siteUrl = $script:txtSiteUrl.Text
|
||||
$clientId = $config.ClientId
|
||||
$clientSecret = $config.ClientSecret
|
||||
|
||||
if (-not $siteUrl) {
|
||||
throw "Please enter a Site URL"
|
||||
}
|
||||
|
||||
Connect-PnPOnline -Url $siteUrl -ClientId $clientId -ClientSecret $clientSecret `
|
||||
# Remove client secret auth and use interactive auth instead
|
||||
Connect-PnPOnline -Url $siteUrl -Interactive `
|
||||
-WarningAction SilentlyContinue `
|
||||
-Tenant "sutterhill" ` # Match your tenant name
|
||||
-Scopes @("AllSites.FullControl") # Required for folder browsing
|
||||
-Tenant "sutterhill" `
|
||||
-Scopes @("AllSites.FullControl")
|
||||
|
||||
return $true
|
||||
}
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
{
|
||||
"TempLibrary": "Documents/Temp",
|
||||
"ClientId": "dcb744a3-96ee-4521-bb35-9909146d3a13",
|
||||
"SiteUrl": "https://sutterhill.sharepoint.com/sites/tax",
|
||||
"ProductionLibrary": "Documents",
|
||||
"ClientSecret": "9NR8Q~GHuB2gtdMXK0N6WbwtOFokXoXa~924Ebso",
|
||||
"TenantId": "sutterhill"
|
||||
"ProductionLibrary": "Documents"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user