针对.Net Odata Web Api使用Excel Power Query进行身份验证

问题描述:

我正在尝试使用Power Query下载使用.net Web Api 2和OData v4 nuget包创建的Odata Feed.

I am trying to use Power Query to download an Odata Feed that I created using .net Web Api 2 and the OData v4 nuget package.

我正在尝试访问需要身份验证的Odata提要.在超级查询中编辑身份验证类型时,我从没看到请求中通过身份验证密钥.

I'm trying to access an Odata feed that requires authentication. When I edit the authentication type in power query, I'm never seeing the authentication key come through in the request.

如何配置Power Query以使用特定类型的身份验证?

How do you configure Power Query to use a specific type of authentication?

奖金:我使用的是OAuth,所以我将如何配置电源查询以发送带有包含"Authorization Bearer:token_here"的auth数据的标头

Bonus: I'm using OAuth, so how would I configure power query to send in a header with auth data that includes "Authorization Bearer:token_here"

Web API凭据用于向URL查询中添加秘密值(即,您对某些网站的API密钥).

Web API credentials are for putting a secret value into to the URL query (i.e. your API key for some website).

当前无法从凭据对话框在Power Query中添加自己的Bearer令牌.

There's currently no way to add your own Bearer token in Power Query from the credential dialog.

它的安全性较差并且无法刷新,但是您可以使用OData.Feed的Header参数直接对凭据进行硬编码:

It's less secure and can't be refreshed, but you can hardcode your credential directly using OData.Feed's Header parameter:

= OData.Feed("http://localhost/", null, [Headers = [Authorization = "Bearer token_here" ] ])

(或者,将服务器配置为接受Power Query支持的基本身份验证可能更容易.)

(Alternatively, it might be easier to configure your server to accept Basic auth, which is supported in Power Query.)