I am using ADAL4j to attempt to authenticate to our onprem sharepoint instance (which itself is using AAD to authenticate as an enterprise app) to authenticate users when coming in through the standard flow.
I have set up my consumer AAD app to require the permission to "access {on prem sharepoint enterprise app}". I am then making a request to a url that looks like:
https://login.microsoftonline.com/{tenant}/oauth2/authorize?
response_type=code&scope=user_impersonation&
response_mode=form_post&
redirect_uri={uri that is registered in my app}&
client_id={my app id}&
resource={onprem sharepoint enterprise app id}&
state={GUID}&nonce={GUID}
The response I receive is 401 UNAUTHORIZED:
{
"error": "invalid_client",
"error_description": "Invalid audience Uri '{onprem sharepoint enterprise app id}'."
}
Any ideas on what could be going wrong here? My searches have not been very fruitful and logically it seems like it should work. Is there some setting on the enterprise app side of things to allow certain clients to access the resource?
Thanks for the help!