Microsoft Graph Identity Java-选定的用户帐户在租户“ Microsoft Services”中不存在

问题描述 投票:0回答:1

我想在Java应用程序中访问用户的Outlook日历。为此,我正在尝试使用Microsoft Graph API。

我正在关注本教程:https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-v2-java-webapp,其代码在此处:https://github.com/Azure-Samples/ms-identity-java-webapp/tree/master/msal-java-webapp-sample

我在类型为Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)的portal.microsoft.com上创建了应用程序>

我已经创建了keystore.p12并将其复制到资源目录。

我的application.properties是:

#AAD configuration
aad.clientId=my client id
aad.authority=https://login.microsoftonline.com/my tenant id/
aad.secretKey=my secret key
aad.redirectUriSignin=https://localhost:8443/msal4jsample/secure/aad
aad.redirectUriGraph=https://localhost:8443/msal4jsample/graph/me
aad.msGraphEndpointHost=https://graph.microsoft.com/

#SSL configuration
server.port=8443
server.servlet.session.cookie.secure=true
server.ssl.key-store=classpath:keystore.p12
server.ssl.key-store-password=password
server.ssl.key-store-type=PKCS12
server.ssl.key-alias=testCert
server.ssl.key-password=password

当我运行该应用程序并访问https://localhost:8443时,出现带有登录按钮的页面。当我单击“登录”按钮时,我被重定向到可以在Outlook帐户中进行选择的页面。网址为:

https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=code&response_mode=form_post&redirect_uri=https%3A%2F%2Flocalhost%3A8443%2Fmsal4jsample%2Fsecure%2Faad&client_id=ca146462-8880-424c-b629-cc7c0d0fb1b3&scope=openid+offline_access+profile&prompt=select_account&state=69a2ac0f-abac-46ad-b525-88f0b70182b7&nonce=9278f424-6858-4e22-bb13-7b13894abda7

选择帐户时,出现以下错误:

所选用户帐户在租户“ Microsoft服务”中不存在并且无法访问该应用程序该租户中的“ ca146462-8880-424c-b629-cc7c0d0fb1b3”。账户首先需要在租户中添加为外部用户。请用一个不同的帐户。

enter image description here

我已添加重定向URIenter image description here

为什么会出现错误?

更新:

我已将application.properties中的权限更改为https://login.microsoftonline.com/common,因此现在进入“选择帐户”页面。但是,当我选择一个帐户时,出现403禁止错误。

我想在Java应用程序中访问用户的Outlook日历。为此,我尝试使用Microsoft Graph API。我正在关注本教程:https://docs.microsoft.com/zh-cn/azure/active -...

java azure microsoft-graph msal microsoft-identity-platform
1个回答
0
投票

将解决方案复制到juunas提到的评论中:

© www.soinside.com 2019 - 2024. All rights reserved.