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({
|
$btnSaveConfig.Add_Click({
|
||||||
Save-Config -SiteUrl $txtSiteUrl.Text `
|
Save-Config -SiteUrl $txtSiteUrl.Text `
|
||||||
-ProductionLibrary $txtProdLib.Text `
|
-ProductionLibrary $txtProdLib.Text `
|
||||||
-TempLibrary $txtTempLib.Text `
|
-TempLibrary $txtTempLib.Text
|
||||||
-ClientId $config.ClientId `
|
|
||||||
-ClientSecret $config.ClientSecret
|
|
||||||
})
|
})
|
||||||
|
|
||||||
$form.Controls.AddRange(@(
|
$form.Controls.AddRange(@(
|
||||||
|
|||||||
@ -19,17 +19,13 @@ function Save-Config {
|
|||||||
param(
|
param(
|
||||||
[string]$SiteUrl,
|
[string]$SiteUrl,
|
||||||
[string]$ProductionLibrary,
|
[string]$ProductionLibrary,
|
||||||
[string]$TempLibrary,
|
[string]$TempLibrary
|
||||||
[string]$ClientId,
|
|
||||||
[string]$ClientSecret
|
|
||||||
)
|
)
|
||||||
|
|
||||||
$config = @{
|
$config = @{
|
||||||
SiteUrl = $SiteUrl
|
SiteUrl = $SiteUrl
|
||||||
ProductionLibrary = $ProductionLibrary
|
ProductionLibrary = $ProductionLibrary
|
||||||
TempLibrary = $TempLibrary
|
TempLibrary = $TempLibrary
|
||||||
ClientId = $ClientId
|
|
||||||
ClientSecret = $ClientSecret
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$config | ConvertTo-Json | Set-Content $configPath
|
$config | ConvertTo-Json | Set-Content $configPath
|
||||||
@ -38,17 +34,16 @@ function Save-Config {
|
|||||||
function Connect-SharePoint {
|
function Connect-SharePoint {
|
||||||
try {
|
try {
|
||||||
$siteUrl = $script:txtSiteUrl.Text
|
$siteUrl = $script:txtSiteUrl.Text
|
||||||
$clientId = $config.ClientId
|
|
||||||
$clientSecret = $config.ClientSecret
|
|
||||||
|
|
||||||
if (-not $siteUrl) {
|
if (-not $siteUrl) {
|
||||||
throw "Please enter a Site URL"
|
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 `
|
-WarningAction SilentlyContinue `
|
||||||
-Tenant "sutterhill" ` # Match your tenant name
|
-Tenant "sutterhill" `
|
||||||
-Scopes @("AllSites.FullControl") # Required for folder browsing
|
-Scopes @("AllSites.FullControl")
|
||||||
|
|
||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
{
|
{
|
||||||
"TempLibrary": "Documents/Temp",
|
"TempLibrary": "Documents/Temp",
|
||||||
"ClientId": "dcb744a3-96ee-4521-bb35-9909146d3a13",
|
|
||||||
"SiteUrl": "https://sutterhill.sharepoint.com/sites/tax",
|
"SiteUrl": "https://sutterhill.sharepoint.com/sites/tax",
|
||||||
"ProductionLibrary": "Documents",
|
"ProductionLibrary": "Documents"
|
||||||
"ClientSecret": "9NR8Q~GHuB2gtdMXK0N6WbwtOFokXoXa~924Ebso",
|
|
||||||
"TenantId": "sutterhill"
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user