Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowTry your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now
Hi,
I connected to the PBI Rest API in PowerQuery.
Currently I am using a static Bearer token, which I copy from the PBI Rest API website.
Copying this static token and pasting in powerbi, allows me to get all the rquired data. It's fine.
Problem comes when i try to use the dynamically generated token:
1. The token seems to be totaly different than the one from the website (even shorter).
2. Is not working. Error mesage: "Expression.Error: Access to the resource is forbidden".
What is your opinion? How can i overcome this?
The PQ code for the dynamic token access
() =>
let
url = "https://login.microsoftonline.com/xxxxxx-xxxxxxxx-xxxx-xxxxxxxxx/oauth2/token",
data = Json.Document(Web.Contents(url,
[
Headers = [
#"Content-Type"="application/x-www-form-urlencoded;charset=UTF=8"],
Content = Text.ToBinary("grant_type = client_credentials&client_id=xxxxxxxxx-xxxxx-xxxx-xxxxxxxxxxxxx&client_secret=xx-xx~xxxxxxxxxxxxxxxxxxxxxxxxx&resource=api://xxxxxxx-xxxx-xxxxxx-xxxxxxxxxxxx")
]
)),
access_token = data[access_token]
in
access_token
thank you in advance!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.