The error message "invalid_grant" with the description "AADSTS65001" indicates that there is an issue with the credentials being used to acquire the token. There are several possible reasons for this error, including incorrect credentials, expired credentials, or incorrect permission settings for the application.
Here are a few steps you can take to troubleshoot this issue:
Check the credentials: Make sure that the username and password being used to acquire the token are correct. If the credentials are incorrect, you will receive an "invalid_grant" error. You can try manually logging in to the application to verify that the credentials are correct.
Check the expiration date of the credentials: If the credentials have expired, you will receive an "invalid_grant" error. Check the expiration date of the credentials and make sure they are still valid.
Check the permission settings for the application: If the application does not have the necessary permissions to access the Dynamics API, you will receive an "invalid_grant" error. Verify that the application has been granted the appropriate permissions to access the Dynamics API.
Try using a different authentication method: If the above steps do not resolve the issue, you can try using a different authentication method. For example, you can try using an OAuth token instead of username and password authentication.
Check the DynamicsWebApi library: Finally, you can also check the DynamicsWebApi library to ensure that it is set up correctly and is making the correct API calls to the Dynamics API.
I hope these steps help you resolve the "invalid_grant" error and successfully acquire the Dynamics token using the 'adal-node' library.