From 39d607a5e0027b6ed0e60e19ac0d7cb7042a141d Mon Sep 17 00:00:00 2001 From: Marcel Meurer Date: Tue, 11 Aug 2020 09:22:30 +0200 Subject: [PATCH] Update --- Sources/OneDrive.psd1 | Bin 8454 -> 8454 bytes Sources/OneDrive.psm1 | 35 ++++++++++++++++++++--------------- readme.md | 4 ++++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Sources/OneDrive.psd1 b/Sources/OneDrive.psd1 index 33bc4ceb4581a1c543cea869e6458851334e43e2..3f087cb97131020dfb64f5bfc710c118593e6cb3 100644 GIT binary patch delta 14 VcmZp3YIEA)!^CL5*_Uaj8~`N{1fT!_ delta 14 VcmZp3YIEA)!^CK|*_Uaj8~`N>1fKu^ diff --git a/Sources/OneDrive.psm1 b/Sources/OneDrive.psm1 index d3a0507..a71531d 100644 --- a/Sources/OneDrive.psm1 +++ b/Sources/OneDrive.psm1 @@ -17,10 +17,6 @@ function Get-ODAuthentication In token mode the accept button in the web form is pressed automatically. .PARAMETER RedirectURI Code authentication requires a correct URI. Use the same as in the app registration e.g. http://localhost/logon. Default is https://login.live.com/oauth20_desktop.srf. Don't use this parameter for token-based authentication. - .PARAMETER DontShowLoginScreen - Suppresses the logon screen. Be careful: If you suppress the logon screen you cannot logon if your credentials are not passed through. - .PARAMETER LogOut - Performs a logout. .EXAMPLE $Authentication=Get-ODAuthentication -ClientId "0000000012345678" @@ -57,11 +53,19 @@ function Get-ODAuthentication { $Type="code" } + if ($RefreshToken -ne "") { write-debug("A refresh token is given. Try to refresh it in code mode.") $body="client_id=$ClientId&redirect_URI=$RedirectURI&client_secret=$([uri]::EscapeDataString($AppKey))&refresh_token="+$RefreshToken+"&grant_type=refresh_token" - $webRequest=Invoke-WebRequest -Method POST -Uri "https://login.microsoftonline.com/common/oauth2$optOauthVersion/token" -ContentType "application/x-www-form-URLencoded" -Body $Body -UseBasicParsing + if ($ResourceId -ne "") + { + # OD4B + $webRequest=Invoke-WebRequest -Method POST -Uri "https://login.microsoftonline.com/common/oauth2$optOauthVersion/token" -ContentType "application/x-www-form-urlencoded" -Body $Body -UseBasicParsing + } else { + # OD private + $webRequest=Invoke-WebRequest -Method POST -Uri "https://login.live.com/oauth20_token.srf" -ContentType "application/x-www-form-urlencoded" -Body $Body -UseBasicParsing + } $Authentication = $webRequest.Content | ConvertFrom-Json } else { @@ -124,16 +128,16 @@ function Get-ODAuthentication } if ($Authentication.code) { - $body="client_id=$ClientId&redirect_URI=$RedirectURI&client_secret=$([uri]::EscapeDataString($AppKey))&code="+$Authentication.code+"&grant_type=authorization_code"+$optResourceId - - if ($ResourceId -ne "") - { - $webRequest=Invoke-WebRequest -Method POST -Uri "https://login.microsoftonline.com/common/oauth2$optOauthVersion/token" -ContentType "application/x-www-form-urlencoded" -Body $Body -UseBasicParsing - } else { - $webRequest=Invoke-WebRequest -Method POST -Uri "https://login.live.com/oauth20_token.srf" -ContentType "application/x-www-form-urlencoded" -Body $Body -UseBasicParsing - } - - $Authentication = $webRequest.Content | ConvertFrom-Json + $body="client_id=$ClientId&redirect_URI=$RedirectURI&client_secret=$([uri]::EscapeDataString($AppKey))&code="+$Authentication.code+"&grant_type=authorization_code"+$optResourceId+"&scope="+$Scope + if ($ResourceId -ne "") + { + # OD4B + $webRequest=Invoke-WebRequest -Method POST -Uri "https://login.microsoftonline.com/common/oauth2$optOauthVersion/token" -ContentType "application/x-www-form-urlencoded" -Body $Body -UseBasicParsing + } else { + # OD private + $webRequest=Invoke-WebRequest -Method POST -Uri "https://login.live.com/oauth20_token.srf" -ContentType "application/x-www-form-urlencoded" -Body $Body -UseBasicParsing + } + $Authentication = $webRequest.Content | ConvertFrom-Json } else { write-error("Cannot get authentication code. Error: "+$ReturnURI) @@ -157,6 +161,7 @@ function Get-ODAuthentication } return $Authentication } + function Get-ODRootUri { PARAM( diff --git a/readme.md b/readme.md index 9631f8e..f1a824e 100644 --- a/readme.md +++ b/readme.md @@ -11,6 +11,10 @@ This OneDrive version (2.0.0 and higher in PowerShellGallery.com) supports: ## What's new +Version 2.2.6 + +- Change: A endpoint change from Microsoft regarding OneDrive personnel is adapted to avoid the error: "AADSTS70011: The provided value for the input parameter 'scope' is not valid. The scope '' is not configured for this tenant" for a refresh token + Version 2.2.5 - Change: A endpoint change from Microsoft regarding OneDrive personnel is adapted to avoid the error: "AADSTS70011: The provided value for the input parameter 'scope' is not valid. The scope '' is not configured for this tenant"