Gerenios / AADInternals

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

AccessToken_utils.ps1 - Cannot bind argument to parameter 'Body' because it is an empty string. #94

Open spaffhazz opened 1 month ago

spaffhazz commented 1 month ago
┌──(user㉿kali)-[/home/user]
└─PS> Get-AADIntAccessTokenForAzureCoreManagement -SaveToCache
    ___    ___    ____  ____      __                        __    
   /   |  /   |  / __ \/  _/___  / /____  _________  ____ _/ /____
  / /| | / /| | / / / // // __ \/ __/ _ \/ ___/ __ \/ __ `/ / ___/
 / ___ |/ ___ |/ /_/ _/ // / / / /_/  __/ /  / / / / /_/ / (__  ) 
/_/  |_/_/  |_/_____/___/_/ /_/\__/\___/_/  /_/ /_/\__,_/_/____/  

 v0.9.3 by @DrAzureAD (Nestori Syynimaa)
Logging in to Microsoft Services                                                                                        
Enter email, phone, or Skype: redacted
Password: ***************
Parse-LoginMicrosoftOnlineComConfig: /home/user/.local/share/powershell/Modules/AADInternals/0.9.3/AccessToken_utils.ps1:2741
Line |
2741 |  … $config = Parse-LoginMicrosoftOnlineComConfig -Body $response.Content
     |                                                        ~~~~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'Body' because it is an empty string.

I'm getting this error whenever I try to get access tokens. Not sure how to fix this. Tried updating AADInternals but it didnt help and I'm on the latest one right now.

jeh0753 commented 1 month ago

Got this error as well on Get-AADIntAccessTokenForAzureCoreManagement -SaveToCache command

spaffhazz commented 4 weeks ago

@jeh0753 were you able to resolve the issue on your end?

weyCC81 commented 2 weeks ago

I have the same issue with Version 0.9.3 and 0.9.4, this includes the following commands:

Get-AADIntAccessTokenForAADGraph -Credentials $cred
Get-AADIntAccessTokenForAADGraph -Credentials $cred -SaveToCache
Get-AADIntAccessTokenForAADGraph -Credentials $cred_a -SaveToCache -OTPSecretKey $totp_a
Get-AADIntAccessTokenForAADGraph -Credentials $cred_a -SaveToCache -OTPSecretKey $totp_a2
Get-AADIntAccessTokenForMSGraph -Credentials $cred
Get-AADIntAccessTokenForMSGraph -Credentials $cred -SaveToCache
Get-AADIntAccessTokenForMSGraph -Credentials $cred_a -SaveToCache -OTPSecretKey $totp_a
Get-AADIntAccessTokenForMSGraph -Credentials $cred -SaveToMgCache # just with 0.9.4 possible

Workaround: Use PowerShell ISE instead of PowerShell in Visual Studio Code

Works:

$PSVersionTable

Name                           Value                                                                                                                                                                             
----                           -----                                                                                                                                                                             
PSVersion                      5.1.22621.3958                                                                                                                                                                    
PSEdition                      Desktop                                                                                                                                                                           
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                           
BuildVersion                   10.0.22621.3958                                                                                                                                                                   
CLRVersion                     4.0.30319.42000                                                                                                                                                                   
WSManStackVersion              3.0                                                                                                                                                                               
PSRemotingProtocolVersion      2.3                                                                                                                                                                               
SerializationVersion           1.1.0.1

Does not work:

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.4
PSEdition                      Core
GitCommitId                    7.4.4
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
weyCC81 commented 2 weeks ago

May related issue: Fix WebCmdlets when -Body is specified but ContentType is not

https://github.com/PowerShell/PowerShell/pull/24145 https://github.com/PowerShell/PowerShell/pull/23952

Tried fix: Upgrade to PowerShell 7.4.5

https://github.com/PowerShell/PowerShell/releases/tag/v7.4.5

Result: Upgrade did not fix the issue