'use CrmServiceClient by Oauth fail with my own AppId

I am using the CrmServiceClient from Microsoft.CrmSdk.XrmTooling.CoreAssembly nuget package. Since the deprecation of Office365 auth type, I need to move to OAuth.

The question is when I use the AppId from MS, my code works, once when I use my own AppId, my code fails.

Here is my code:

//AppId and RedirectUri from MS, this works
var cli = new CrmServiceClient("AuthType=OAuth;[email protected];Password=secret;Url=https://orgname.crm5.dynamics.com;AppId=51f81489-12ee-4a9e-aaae-a2591f45987d;RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;LoginPrompt=Never");
//AppId from my onw app, this fail
var cliFromMyApp = new CrmServiceClient("AuthType=OAuth;[email protected];Password=secret;Url=https://orgname.crm5.dynamics.com;AppId=myappid;RedirectUri=app://myappid;LoginPrompt=Never");

MS AppId and RedirectUri are from this link

My app looks like this:

enter image description here

enter image description here

I have granted this app with Crm and dataverse privileges.

What am I doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source