Since admins can log in successfully, it suggests that consent is still required at an organizational level. Try granting consent for all users explicitly:
- Have the Microsoft 365 admin visit this URL (replace
{tenant_id}
with the client's tenant ID and{client_id}
with your application ID):com/{tenant_id}/adminconsent?client_id={client_id}
https://login.microsoftonline.com/{tenant_id}/adminconsent?client_id={client_id}
- The admin should grant consent for the entire organization instead of per-user approval.
- Once this is done, users should be able to authenticate without hitting the approval screen again.
Also, you need to check this;
Even after approval, users may not have proper access due to an issue in Enterprise Applications.
- In Microsoft Entra ID > Enterprise Applications, find your application.
- Under Permissions, check if the requested permissions are granted organization-wide.
- If permissions still show "Needs admin approval", try re-granting them at the Admin consent section.
Your OAuth URL currently uses prompt=consent
. This forces the user to see the consent prompt every time, which may be problematic if the user's consent is not stored properly. Try removing it and using the default behavior.
Instead of:
bash
CopyEdit
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?prompt=consent
Use:
bash
CopyEdit
https://login.microsoftonline.com/common/oauth2/v2.0/authorize
This ensures that the process does not unnecessarily force a consent prompt.