I am writing a service that will use Microsoft Graph API. To retrieve the access token I have done the following:
- Created a ServicePrincipal w/ "Company Administrator" role using SOAP based IProvisioningWebService (assume that I will have the org admin credential)
Then used the ADAL4J lib to retrieve access token
// clientId = AppPrincipalId created in step#1 Future<AuthenticationResult> future = context.acquireToken( "https://graph.windows.net", clientId, username, password, null);
I am getting following error, is my approach not valid?
com.microsoft.aad.adal4j.AuthenticationException: {"error":"invalid_grant","error_description":"AADSTS65001: The user or administrator has not consented to use the application with ID 'XXXX '. Send an interactive authorization request for this user and resource.\r\nTrace ID: