private async Task <List <Claim> > CheckTwitchOAuth(string providedApiKey)
        {
            if (!providedApiKey.StartsWith("OAuth"))
            {
                return(null);
            }

            TwitchValidateResult validate = await TwitchOAuthHandler.Validate(providedApiKey);

            // if the userId is missing it must mean we got an error back from twitch validate.
            if (string.IsNullOrEmpty(validate.UserId))
            {
                //Response.StatusCode = validate.Status;
                //await Response.WriteAsync(validate.Message);
                return(null);
            }

            // Generate all possible claims from the TwitchValidateResult
            List <Claim> claims = new()
            {
                //new Claim(ClaimTypes.Name, validate.Login),
                new Claim(AuthClaims.ClientId, validate.ClientId),
                new Claim(AuthClaims.Login, validate.Login),
                new Claim(AuthClaims.Scopes, string.Join(',', validate.Scopes)),
                new Claim(AuthClaims.UserId, validate.UserId),
                new Claim(AuthClaims.ExpiresIn, validate.ExpiresIn.ToString()),
            };

            SetRoles(validate, claims);

            return(claims);
        }
        private void SetRoles(TwitchValidateResult validate, ICollection <Claim> claims)
        {
            // userId from validate
            if (!int.TryParse(validate.UserId, out int userId))
            {
                return;
            }

            string         claimRole = string.Empty;
            BotSpecialUser dbUser    = _ttsDbContext.BotSpecialUsers.Find(userId);

            if (dbUser?.IsIrcBot ?? false)
            {
                claimRole = Roles.Roles.IrcBot;
            }
            else if (dbUser?.IsBotOwner ?? false)
            {
                claimRole = Roles.Roles.BotOwner;
            }
            else if (dbUser?.IsBotAdmin ?? false)
            {
                claimRole = Roles.Roles.BotAdmin;
            }

            // Get channelId from Route
            else if (Request.RouteValues.TryGetValue("channelId", out object channelIdStr) &&
                     channelIdStr != null &&
                     int.TryParse(channelIdStr.ToString(), out int channelId)
                     )
            {
                // Broadcaster check
                if (channelId == userId)
                {
                    claimRole = Roles.Roles.ChannelBroadcaster;
                }

                // Mod check
                // TODO: Mod check from ThreeLetterApi
                else if (channelId == 1234)
                {
                    claimRole = Roles.Roles.ChannelMod;
                }
            }

            if (!string.IsNullOrEmpty(claimRole))
            {
                claims.Add(new Claim(ClaimTypes.Role, claimRole));
            }
        }