我想在我的 Java 应用程序中访问用户的 Outlook 日历。为此,我尝试使用 Microsoft Graph API。
我正在关注本教程: https://learn.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
我在 Portal.microsoft.com 上创建了类型为任何组织目录(任何 Azure AD 目录 - Multi-Tenancy )中的帐户和个人 Microsoft 帐户(例如 Skype、Xbox)的应用
我已创建 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 帐户中进行选择的页面。网址是:
当我选择帐户时,出现以下错误:
Selected user account does not exist in tenant 'Microsoft Services' and cannot access the application 'ca146462-8880-424c-b629-cc7c0d0fb1b3' in that tenant. The account needs to be added as an external user in the tenant first. Please use a different account.
为什么我会收到错误消息?
更新:
我将application.properties中的权限更改为https://login.microsoftonline.com/common ,所以现在我进入“选择帐户”页面。但是当我选择帐户时,我收到 403 Forbidden 错误。
最佳答案
403 Forbidden 是您所遵循的教程的问题。由于某些浏览器中的samesite更新,response_mode需要为query(而不是form_post)。如果您尝试再次运行该示例,它应该可以工作
关于java - Microsoft Graph Identity Java - 租户中不存在选定的用户帐户 'Microsoft Services',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61674188/