Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jm420a
Frequent Visitor

Authenticating to Azure after Retrieving API Key

Greetings, 
 I have the below code, which each step passes the correct information, however, I'm still asked to specify my credentials. 
On the #Authorization line I pass the access_token from the recently retrieved POST request, and stepping through the applied steps, it retrieves the correct value.  Everything seems to work okay, other than the authentication piece. 

If anyone has any insight on this, I would greatly appreciate it. 

 

 

let
    // Define your Microsoft Graph API URL for audit logs
    apiUrl = "https://graph.microsoft.com/v1.0/auditLogs/directoryAudits",
    //Get value of access_token from Post Request
    AccessToken = fnGetAzureToken{0}[access_token],

    // Define the required headers (you may need to add more headers as necessary)
    headers = [
        #"Authorization" = "Bearer " & AccessToken,
        #"Content-Type" = "application/json"
    ],

    // Create the HTTP request
    auditLogsRequest = Web.Contents(apiUrl, [Headers=headers]),

    // Parse the JSON response
    auditLogsResponse = Json.Document(auditLogsRequest)
in
    auditLogsResponse

 

 

 

1 REPLY 1
DNMAF
Responsive Resident
Responsive Resident

Hi,

just a few thoughts:

  • Did you check the content of AccessToken? 
    • Does fnGetAzureToken really return a list and the first member (record) of that list includes your token?
  • Have your tried to add an #"Accept" = "application/json" to your header section?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors