gpt4 book ai didi

python - 尝试验证 Power Bi Web 应用程序时,重定向 url 不返回授权代码

转载 作者:行者123 更新时间:2023-12-03 04:31:06 25 4
gpt4 key购买 nike

我使用 python 3.5.1 编写了一段代码来获取授权代码,以便获取用于访问某些 Power BI 资源的访问 token 。

Web 应用程序已向 Azure AD 注册,我获取了客户端 ID 和客户端 key 并设置了权限。

我构建了查询字符串并将其传递给 requests 库的 get 函数。

authstring=https://login.windows.net/common/oauth2/authorize?response_type=code&client_id=xxxxx-xxxx-xxxx-xxxx&resource=https://analysis.windows.net/powerbi/api&redirect_uri=https://login.live.com/oauth20_desktop.srf

requests.get(authstring)

但它不断重定向到

https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=xxxxx-xxxx-xxxx-xxxx&resource=https://analysis.windows.net/powerbi/api&redirect_uri=https://login.live.com/oauth20_desktop.srf

用代码代替重定向网址

https://login.live.com/oauth20_desktop.srf?code=xxXXXXXaaaxaaaxxxxxx....

当我将查询字符串放入浏览器时,它会重定向并返回代码。

我不确定我错过了什么。有谁知道如何解决这个问题或知道解决方法吗?

最佳答案

根据我的理解,您想要对 Power BI 资源与 Python 集成进行身份验证,但我不知道您的 python 应用程序是客户端应用程序还是 Web 应用程序。

可以引用官方文档Authenticate to Power BI service知道该怎么做。

根据您的描述,我认为您想要获取用于请求Power BI资源的访问 token ,而不是通过单点登录访问Power BI。所以你需要做 Resource Management Authentication使用 Python SDK 和包 adal .

希望有帮助。

如有任何疑问,请随时告诉我。

关于python - 尝试验证 Power Bi Web 应用程序时,重定向 url 不返回授权代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36435012/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com