microsoft / vscode-azure-account

Common Azure Login extension for VS Code
https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account
Other
138 stars 131 forks source link

Connect-EXOPSSession not working in VS Code Cloud Shell #174

Open joergrenn opened 4 years ago

joergrenn commented 4 years ago

I am trying to connect to Exchange Online in a VS Code Cloud Shell, but the Connect-EXOPSSession command fails everytime. If I use a cloud shell in the browser on shell.azure.com the Connect-EXOPSSession command works without issues. The error message I in VS Code is:

Connect-EXOPSSession -Verbose

VERBOSE: Loading module from path '/usr/local/share/powershell/Modules/EXOPSSessionConnector/Microsoft.Exchange.Management.ExoPowershellModule.dll'. VERBOSE: Importing cmdlet 'New-ExoPSSession'. New-ExoPSSession: /usr/local/share/powershell/Modules/EXOPSSessionConnector/EXOPSSessionConnector.psm1:288
Line | 288 | … PSSession = New-ExoPSSession -ConnectionUri $ConnectionUri -AzureADAu … | ~~~~~~~~~~~~~ | HttpRequestExceptionMessage: Response Status Code BadRequest, Request Method GET, Request Uri | http://localhost:50342/oauth2/token?resource=https%3A%2F%2Foutlook.office365.com%2F&api-version=2018-02-01, Response Contetnt {"error":{"code":"invalid_request","message":"No token found for audience | https://outlook.office365.com/"}}

jhochwald commented 1 year ago

I have the same issue: VERBOSE: Importing cmdlet 'New-ExoPSSession'. New-ExoPSSession: HttpRequestExceptionMessage: Response Status Code BadRequest, Request Method GET, Request Uri http://localhost:50342/oauth2/token?resource=https%3A%2F%2Foutlook.office365.com%2F&api-version=2018-02-01, Response Contetnt {"error":{"code":"invalid_request","message":"Timeout waiting for token from portal. Audience: https://outlook.office365.com/"}}

I tried the connect-eXOPSSession without any parameters and with the following: connect-eXOPSSession -Verbose -BypassMailboxAnchoring -ConnectionUri https://outlook.office365.com/PowerShell-LiveID/?BasicAuthToOAuthConversion=true. The result is the same, with and without parameters: Timeout while waiting for the Token from the portal.

If i try the same within the CloudShell of the admin center is works just fine:


PS /home/joerg> Connect-EXOPSSession
WARNING: The names of some imported commands from the module 'tmp_l5z1444b.lsw' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
WARNING: The names of some imported commands from the module 'tmp_l5z1444b.lsw' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.```