Trimble Connect User Forum

 View Only
  Thread closed by the administrator, not accepting new replies.
  • 1.  Authentication Error

    Posted 12-04-2022 09:36
    Edited by Osama Ahmed Hassan 12-04-2022 12:41
      |   view attached
    No replies, thread closed.
    Hi , 
    I start first .Net application windows form to collect all project on Trimble connect Europe region and try to see help and examples but still have an error and couldn't know why ?
    Here is a copy of code i got an error while using Method LoginAsync  for check too  , i used     
    private const string ServiceUri = "https://app.qa.connect.trimble.com/tc/api/2.0/";
    public static readonly string AppName = "Tkis_Model_Integration";
    public static readonly string RedirectUrl = "http://localhost";


     
     public async Task UserTrimbleConnectClient()
    {
    var authCtx = new AuthenticationContext(Config.ClientCredentials, new TokenCache())
    {
    AuthorityUri = new Uri(Config.AuthorityUrl)
    };
    AuthCodeCredentialsProvider credentialsProvider = new AuthCodeCredentialsProvider(authCtx);
    credentialsProvider.AuthenticationRequest = new InteractiveAuthenticationRequest()
    {
    Scope = $"openid {string.Join(" ", Config.ClientCredentials.Name)}"
    };
    var token = await authCtx.AcquireTokenAsync(credentialsProvider.AuthenticationRequest);
    try
    {

    using (var client = new TrimbleConnectClient(new TrimbleConnectClientConfig { ServiceURI = new Uri(ServiceUri) }, credentialsProvider))
    {
    //await client.InitializeTrimbleConnectUserAsync();
    await client.LoginAsync(token.IdToken);      // This Method have an error in  input value i coudn't know why ?
    var projects = (await client.GetProjectsAsync()).ToArray();

    foreach (var p in projects)
    {
    ProjectNames.Add(p.Name);
    }
    }
    }
    catch (Exception)
    {

    throw;
    }
    }

    ------------------------------
    Osama Ahmed Hassan
    ------------------------------