public async Task <GrantedToken> GetTokenByRefreshTokenGrantType(RefreshTokenGrantTypeParameter refreshTokenGrantTypeParameter, X509Certificate2 certificate = null) { if (refreshTokenGrantTypeParameter == null) { throw new ArgumentNullException(nameof(refreshTokenGrantTypeParameter)); } var processId = Guid.NewGuid().ToString(); try { _eventPublisher.Publish(new GrantTokenViaRefreshTokenReceived(Guid.NewGuid().ToString(), processId, _payloadSerializer.GetPayload(refreshTokenGrantTypeParameter), 0)); _simpleIdentityServerEventSource.StartGetTokenByRefreshToken(refreshTokenGrantTypeParameter.RefreshToken); _refreshTokenGrantTypeParameterValidator.Validate(refreshTokenGrantTypeParameter); var result = await _getTokenByRefreshTokenGrantTypeAction.Execute(refreshTokenGrantTypeParameter); _simpleIdentityServerEventSource.EndGetTokenByRefreshToken(result.AccessToken, result.IdToken); _eventPublisher.Publish(new TokenGranted(Guid.NewGuid().ToString(), processId, _payloadSerializer.GetPayload(result), 1)); return(result); } catch (IdentityServerException ex) { _eventPublisher.Publish(new OpenIdErrorReceived(Guid.NewGuid().ToString(), processId, ex.Code, ex.Message, 1)); throw; } }