Hello,
I need to create a desktop application that connects automatically to TrimbleConnect, so that the user to not insert user and password every time the application is opped.
I'm using the code from below to get the access token an to create the TrimbleConnectClient.
var newClient = new TrimbleConnectClient(TrimbleConnectConfig.ServiceUri);
try
{
var authCtx = new AuthenticationContext(TrimbleConnectConfig.ClientCredentials, new TokenCache())
{
AuthorityUri = new Uri(TrimbleConnectConfig.AuthorityUri)
};
var userCredentials = new NetworkCredential(user, password);
var token = authCtx.AcquireTokenAsync(userCredentials).Result;
newClient.InitializeTrimbleConnectUserAsync(token.AccessToken);
}
catch(Exception ex)
{
throw ex;
}
When run the code returns an error
Provided Authorization Grant is invalid
Same user and password are working fine when connecting to TrimbleConnect using the login form.
There is something I'm missing for the code to run without errors?
Thank you.