msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Invoke-MgGraphRequest fails due to empty token in custom (air gapped) cloud

Open randomnote1 opened this issue 1 year ago • 2 comments

Describe the bug

I'm attempting to execute Graph API requests using Invoke-MgGraphRequest in a custom air-gapped cloud. However, it is resulting an error:

{
  "error": {
    "code": "InvalidAuthenticationToken",
    "message": "Access token is empty.",
    ...
  }
}

The Connect-MgGraph cmdlet works as expected and returns the welcome message when complete. It doesn't matter what API call is made, they all fail. Some examples of what I've tried:

  • https://<graph api endpoint>/v1.0/me
  • https://<graph api endpoint>/v1.0/reports/getOneDriveUsageAccountDetail(date=2024-04-30)?$format=text/csv

Expected behavior

I expect to get a result (file or json) from the Graph API request.

How to reproduce

Using Microsoft.Graph.Authentication 2.0.0 or newer:

  • Connect-MgGraph -Environment <custom environment name> (use interactive login or a certificate)
  • Invoke-MgGraphRequest -Method GET -InferOutputFileName -Uri 'https://<graph api endpoint>/v1.0/reports/getOneDriveUsageAccountDetail(date=2024-04-30)?$format=text/csv'

SDK Version

v2.0.0 and newer

Latest version known to work for scenario above?

v2.0.0-rc3

Known Workarounds

Downgrade the Microsoft.Graph modules to version v2.0.0-rc3.

Debug output

Unable to provide due to air gap.

Configuration

Issue exists in multiple environments

  • Azure Cloud Shell
  • Windows PowerShell v5.1 on Windows 10 x64
  • Azure Function App using PowerShell 7.2 x64

Other information

No response

randomnote1 avatar May 09 '24 13:05 randomnote1

Hi @randomnote1 ,

Could you please confirm that the latest version 2.19 does not work for you in the same way?

petrhollayms avatar Jun 06 '24 14:06 petrhollayms

Yes, I'm working on getting it moved over. I'll test and get back to you.

randomnote1 avatar Jun 10 '24 16:06 randomnote1