RE: Connecting to Dynamics 365 online using powershell
Hello,
I believe want you need is to connect with application & an application user set up in CRM with application ID:
Connect using the application secret
If you are connecting using an secret configured for the application, you will use the ClientCredential class passing in the clientId and clientSecret rather than a UserCredential with userName and password parameters.
Sample code C#:
===============
string serviceUrl = "yourorg.crm.dynamics.com";
string clientId = "<your app id>";
string secret = "<your app secret>";
AuthenticationContext authContext = new AuthenticationContext("login.microsoftonline.com/common", false);
ClientCredential credential = new ClientCredential(clientId, secret);
AuthenticationResult result = authContext.AcquireToken(serviceUrl, credential);
string accessToken = result.AccessToken;
===============
This could be found from
docs.microsoft.com/.../authenticate-oauth