I want to access a user's outlook calendar in my Java Application. For this I'm trying to use Microsoft Graph APIs.
I'm following this tutorial: https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-v2-java-webapp whose code is here: https://github.com/Azure-Samples/ms-identity-java-webapp/tree/master/msal-java-webapp-sample
I created app on portal.microsoft.com with type Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)
I've created and copied keystore.p12 to resources directory.
My application.properties is:
#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
When I run the application and access https://localhost:8443
, I get the page with Login button. When I click on the Login button, I'm redirected to the page where I can choose among outlook accounts. The URL is:
When I select an account, I'm getting the following error:
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.
Why am I getting the error?
Update:
I changed the authority in application.properties to https://login.microsoftonline.com/common, so now I'm getting the "Pick an account" page. But when I choose an account, I'm getting 403 Forbidden error.