コード例 #1
0
        public IActionResult GetSelfTestToken(Guid participantId)
        {
            if (participantId == Guid.Empty)
            {
                ModelState.AddModelError(nameof(participantId), $"Please provide a valid {nameof(participantId)}");
                return(BadRequest(ModelState));
            }

            var expiresOn     = DateTime.UtcNow.AddMinutes(_kinlyConfiguration.HashExpiresInMinutes).ToUniversalTime().ToString("dd.MM.yyyy-H:mmZ");
            var token         = _hashGenerator.GenerateSelfTestTokenHash(expiresOn, participantId.ToString());
            var tokenResponse = new TokenResponse {
                ExpiresOn = expiresOn, Token = token
            };

            return(Ok(tokenResponse));
        }