public void ApproveDeviceCodeGrant(string userCode)
        {
            DeviceCodeGrant grant = DeviceGrants.FirstOrDefault(x => x.UserCode == userCode);

            if (grant is null)
            {
                throw new Exception($"Invalid user code '{userCode}'");
            }

            grant.Approved = true;
        }
        public bool IsDeviceCodeGrantApproved(string deviceCode)
        {
            DeviceCodeGrant grant = DeviceGrants.FirstOrDefault(x => x.DeviceCode == deviceCode);

            if (grant is null)
            {
                throw new Exception($"Invalid device code '{deviceCode}'");
            }

            return(grant.Approved);
        }
        public DeviceCodeGrant CreateDeviceCodeGrant(TestOAuth2ServerTokenGenerator generator, string[] scopes)
        {
            string deviceCode = generator.CreateDeviceCode();
            string userCode   = generator.CreateUserCode();

            var grant = new DeviceCodeGrant(userCode, deviceCode, scopes);

            DeviceGrants.Add(grant);

            return(grant);
        }