admin管理员组文章数量:1404073
I'm using Power BI with a REST API as a data source. The API requires authentication via a JWT token. In Power BI Desktop, I created a Power Query function that retrieves a new token using credentials and then applies it to API requests. This works perfectly on my local machine.
However, after publishing to Power BI Service, I can't connect to the API. The dataset shows as offline due to credential issues, and I'm unable to save authentication settings (Anonymous/Organizational). It seems Power BI Service does not execute the function that retrieves the token, causing authentication to fail.
Is there any way to make this work? Does Power BI Service support API authentication with dynamic tokens, or do I need an alternative approach?
I already tried to save the credentials as Anonymous and Organizational, but it didn't save. I also tried to find a way to define a header in Power BI Service with the username and password used in my API to get the JWT token, but I don't think there's a way to do this in app.powerbi.
I expect my report to be able to access my API in the app.powerbi, use the function I created to generate a JWT Token, access the route defined in my query and refresh the table I published
Function to obtain a new JWT Token
let
GetAuthToken = () as text =>
let
authUrl = "https://localhost/api/auth/login",
authBody = "{""Nome"":""admin"",""senha"":""Teste123""}",
authHeaders = [
#"Content-Type" = "application/json",
#"Accept" = "application/json"
],
authResponse = Json.Document(Web.Contents(authUrl, [
Headers = authHeaders,
Content = Text.ToBinary(authBody),
ManualStatusHandling = {400, 401, 403}
])),
token = authResponse[token] // Ajustado para o nome correto
in
token
in
GetAuthToken
Power Query of a example table
let
Fonte = Json.Document(Web.Contents("http://localhost/api/operacoes/almoxarifados", [Headers=[Authorization="Bearer " & #"GET Access Token"()]])),
#"Convertido para Tabela" = Table.FromList(Fonte, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Column1 Expandido" = Table.ExpandRecordColumn(#"Convertido para Tabela", "Column1", {"codigo", "filial", "nome", "ult_Qtd", "ult_Custo", "almoxarifado_de_Venda"}, {"codigo", "filial", "nome", "ult_Qtd", "ult_Custo", "almoxarifado_de_Venda"})
in
#"Column1 Expandido"
本文标签: powerbiPower BI API Authentication Issue After Publishing (JWT Token)Stack Overflow
版权声明:本文标题:powerbi - Power BI API Authentication Issue After Publishing (JWT Token) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744228925a2596232.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论