Your code attempts to use Windows impersonation to access the cloud-based Dynamics 365, which is totally different from on-premises Dynamics. Cloud-based Dynamics 365 does not support Windows Authentication or Windows Identity-based impersonation for authentication. Instead, it relies on OAuth 2.0 for authentication, which requires an Azure Active Directory (AAD) registered application, so you have to use one of the authentication mechanism mentioned here: https://learn.microsoft.com/en-us/power-apps/developer/data-platform/authenticate-oauth
Please mark this answer as verified if you are ok with answer and let me know if you have any other questions. thanks