【发布时间】:2020-08-20 07:16:23
【问题描述】:
我正在尝试以编程方式将 reply_url 添加到 Azure 应用注册,但我收到了 GraphErrorException: Insufficient privileges to complete the operation。
问题是我不明白我的应用注册需要哪些权限。
基本上我是在使用应用注册的凭据来更改它自己的reply_urls。
权限集是User.Read 和Application.ReadWrite.OwnedBy。两者都批准了。
我错过了哪一个?我怎样才能知道?
这是我正在使用的 SDK:azure-graphrbac==0.61.1
我的代码如下所示:
class GraphClient:
def __init__(self, client_id, client_secret, tenant_id, object_id):
self._credentials = ServicePrincipalCredentials(
client_id=client_id,
secret=client_secret,
tenant=tenant_id,
resource="https://graph.windows.net"
)
self._graph_client = GraphRbacManagementClient(
credentials=self._credentials,
tenant_id=tenant_id
)
self._application = self._graph_client.applications.get(object_id)
def get_reply_urls(self) -> List[str]:
return self._application.reply_urls
def add_reply_url(self, reply_url) -> None:
reply_urls: list = self.get_reply_urls()
self._graph_client.applications.patch(
self._application.app_id,
ApplicationUpdateParameters(
reply_urls=[
*reply_urls,
reply_url]
)
)
【问题讨论】:
-
您好,能否分享一下您添加的权限的屏幕截图(Azure 应用注册的“API 权限”选项卡)?
-
请参考我下面提供的解决方案。
标签: python azure azure-ad-graph-api