Esempio n. 1
0
 private void EnsureValidBearerToken(IdentityClientInfo clientInfo)
 {
     if (clientInfo.BearerTokenInfo == null || DateTime.UtcNow > clientInfo.BearerTokenInfo.ExpireDate)
     {
         RefreshBearerToken(clientInfo);
     }
 }
Esempio n. 2
0
        private void RefreshBearerToken(IdentityClientInfo clientInfo)
        {
            if (clientInfo == null)
            {
                throw new ArgumentNullException(nameof(clientInfo));
            }

            // TODO: call the Identity service to receive a new bearer token
            Console.WriteLine($"Calling the Koa Identity service to retrieve a valid bearer token ({clientInfo.ClientId}/{clientInfo.ClientSecret})...");

            // simulate a serice call
            Thread.Sleep(100);

            // TODO: set the 'clientInfo.BearerTokenInfo' to the BTI retrieved from the Identity service
            clientInfo.BearerTokenInfo = new BearerTokenInfo(clientInfo.ExpiresInSeconds);
        }