jevgenijmart
8 years agoRegular Visitor
Status:
New
Error getting OData from Microsoft Graph: Access to the resource is forbidden
Hello, I am getting an error "Access to the resource is forbidden" when trying to access Microsoft Graph in Power BI Desktop report. Microsoft Graph URL is https://graph.microsoft.com/v1.0/devic...
jevgenijmart
8 years agoRegular Visitor
Thanks a lot for sharing, Anonymous!
Code seems to be ok, but I am getting an error: Formula.Firewall: Query 'Devices (Azure AD)' (step 'Source') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.
Anyone has a clue why this is happening?
AzureAccessToken query is returing token successfully, but I can't use it in OData.Feed method.
Parameters:
Azure Graph API Url = https://graph.microsoft.com/v1.0/
Azure Tenant Id = ...
Azure Application Id = ...
Azure Application Client Secret = ...
Query: AzureAccessToken
let
TokenUri = "https://login.windows.net/" & #"Azure Tenant Id" & "/oauth2/token",
ResourceId = "https://graph.microsoft.com",
TokenResponse = Json.Document(Web.Contents(TokenUri,
[
Content = Text.ToBinary(Uri.BuildQueryString([client_id = #"Azure Application Id", resource = ResourceId, grant_type = "client_credentials", client_secret = #"Azure Application Client Secret"])),
Headers = [Accept = "application/json"], ManualStatusHandling = {400}
]
)),
AzureAccessToken = TokenResponse[access_token]
in
AzureAccessToken
Query: Devices (Azure AD)
let
Source = OData.Feed(#"Azure Graph API Url" & "devices", [Authorization = "Bearer " & AzureAccessToken])
in
Source