You can send credentials two ways in Power Query: inline in the Headers record (quick, but the value is stored in the query), or via Power BI's managed data-source credentials (Anonymous, Basic, Web API key). For sharing and scheduled refresh, prefer managed credentials.
API key in a header
Json.Document(
Web.Contents("https://api.ifsjaipur.cloud", [
RelativePath = "playground/auth/api-key",
Headers = [ #"x-api-key" = "YOUR_API_KEY" ]
])
)Bearer token
Json.Document(
Web.Contents("https://api.ifsjaipur.cloud", [
RelativePath = "playground/auth/bearer",
Headers = [ Authorization = "Bearer YOUR_BEARER_TOKEN" ]
])
)Basic auth (App ID / App Secret)
Either set the data source credential to "Basic" (recommended — Power Query builds the header), or build it yourself with Binary.ToText:
let
Auth = "Basic " & Binary.ToText(Text.ToBinary("APP_ID:APP_SECRET"), BinaryEncoding.Base64),
Source = Json.Document(
Web.Contents("https://api.ifsjaipur.cloud", [
RelativePath = "playground/auth/basic",
Headers = [ Authorization = Auth ]
])
)
in
SourceTip · For OAuth2 client credentials, POST to https://api.ifsjaipur.cloud/oauth/token to get an access_token, then send it as a Bearer header on the data request — the same two-step you do everywhere else, just written in M.
- Headers keys with special characters use the #"..." quoting syntax, e.g. #"x-api-key".
- Never commit real keys into shared .pbix files — use data source credentials or parameters.