AnsweredAssumed Answered

Session Invalid after API update

Question asked by Jan Stucky on Aug 13, 2019
Latest reply on Sep 19, 2019 by Jan Stucky

Hi everyone

 

C# MVC.net 5 .net 4.6.1 question here.

 

Today I updated the nugets for Trimble.Connect.Client to 2.4.77 and Trimble.Identity to 1.1.25 because of updates on the Trimble Connect API.

 

Now Trimble.Connect.Client.LoginAsync is obsolete, why I try to get initialize the trimble user with Trimble.Connect.Client.LoginAsync.InitializeTrimbleConnectUserAsync, but I get an "Invalid Session" exception every time I call this method.

 

I also tried to investigate this problem by implementing your sample code from the documentation:

 

var settings = Config.TrimbleConnectConfigSection.Current;
const string clientCredentialName = "Plotfabrik";

var clientCredentials = new ClientCredential(settings.ClientId, settings.ClientSecret, clientCredentialName) {
   RedirectUri = new Uri(settings.RedirectUri)
};
var authCtx = new AuthenticationContext(clientCredentials, new TokenCache()) {

   AuthorityUri = new Uri(settings.AuthorityUri)

};
var accessToken = await authCtx.AcquireTokenAsync(RefreshOptions.IdToken);

try {
   using (var client = new TrimbleConnectClient(settings.ServiceUri))
   {
      await client.InitializeTrimbleConnectUserAsync(accessToken.AccessToken);
   }
} catch(Exception e) {
   return false;
}

 

Can somebody explain what I am doing wrong or is it the APIs fault?

I am quite stuck here and I need to get the client running again to serve our customers with the trimble files in our web application.

Outcomes