为什么我无法从 Graph Explorer 调用与从 Az 执行 Powershell 相同的 API?
我正在使用 Powershell 连接到 Az
:
Connect-AzureAd
然后,我尝试执行命令:
Get-AzRoleAssignment -ResourceGroupName 'devtest' -ResourceName 'SA-name' -ResourceType 'Microsoft.Storage/storageAccounts'
并且一切正常,我得到了结果。使用 -Debug
标志,我看到 Az
正在执行 API 方法:
POST https://graph.microsoft.com/v1.0/directoryObjects/microsoft.graph.getByIds
然后,我转到 Graph Explorer ,我尝试使用与我登录 Az
相同的帐户从那里执行相同的方法,并且我得到了调用授权错误:
当我检查执行此操作需要什么样的权限时,我发现我的帐户无法授予 Directory.Read.All
权限。
所以问题是,为什么我可以使用同一帐户从 Powershell
执行更多操作而不是 graph
?
I am connecting to Az
using Powershell:
Connect-AzureAd
Then, i am trying execute command:
Get-AzRoleAssignment -ResourceGroupName 'devtest' -ResourceName 'SA-name' -ResourceType 'Microsoft.Storage/storageAccounts'
And eveything work fine, i am getting results. with -Debug
flag i see, that Az
executing API method:
POST https://graph.microsoft.com/v1.0/directoryObjects/microsoft.graph.getByIds
Then, i go to Graph Explorer and i try to execute the same method from there with the same account that i logged into Az
and i getting an authorization error from call:
When i check, what kind of privilage i need to for perform this action i can see that there is no way that my account have Directory.Read.All
permission granted.
So the question is, why i am allowed to do more actions from Powershell
tha graph
using same account?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请允许我先将其作为答案发布,以获得更好的描述。
根据屏幕截图顶部的错误提示,您是否同意该选项卡中的所有权限?
顺便问一下,您用于在 powershell 中生成访问令牌的 azure ad 应用程序与 graph explorer 的应用程序相同吗?当我解码由 Graph Explorer 生成的访问令牌时,我发现它是由名为
Graph explorer(官方网站)
的应用程序生成的。我认为这可能会导致你的问题。Pls allow me post it as the answer first for a better desription.
Based on the Error tip on the top of your screenshoot, if you've consent all the permissions in that tab?
By the way, is the azure ad application you used to generate access token in powershell the same as the application for graph explorer? When I decode the access token generated by graph explorer, I found it's generated by app named
Graph explorer (official site)
. I think it may lead to your issue.