Gerenios / AADInternals

AADInternals PowerShell module for administering Azure AD and Office 365
http://aadinternals.com/aadinternals
MIT License
1.2k stars 210 forks source link

Error on AccessToken code in Get-SPOSiteUsers #48

Closed AsadoLover1 closed 1 year ago

AsadoLover1 commented 1 year ago

Using Token auth with Get-SPOSiteUsers , I found that it is using a non-existant variable and failing with the following error:

The audience of the access token (https://xxxxxx.sharepoint.com) is wrong. Should be https://.sharepoint.com!

This is because line 140 in SPO.ps1: $AccessToken = Get-AccessTokenFromCache -AccessToken $AccessToken -Resource "https://$Tenant.sharepoint.com/" -ClientId "9bc3ab49-b65d-410a-85ad-de819febfddc"

The variable $Tenant do not exists, this bug is corrected writing: $AccessToken = Get-AccessTokenFromCache -AccessToken $AccessToken -Resource $Site -ClientId "9bc3ab49-b65d-410a-85ad-de819febfddc"

(Note that site should be in https://tenant.sharepoint.com format. Thanks for your project.

NestoriSyynimaa commented 1 year ago

Thanks for reporting! This is now fixed and will be included in the next release.