def refresh_token_scope(request):
    client_id = os.environ.get('TWITCH_APP_ID', None)
    helix_scopes = list(TwitchAPIScope.objects.filter(required=True).values_list('scope', flat=True))
    eventsub_scopes = list(TwitchEventSubSubscription.objects.filter(active=True).values_list('scope_required', flat=True))
    scopes = list(set(((settings.TOKEN_SCOPES + eventsub_scopes) + helix_scopes)))
    scopes = list(filter((lambda x: (x is not None)), scopes))
    scope = ' '.join(scopes)
    url = f'https://id.twitch.tv/oauth2/authorize?client_id={client_id}&redirect_uri={settings.BASE_URL}/twitch-callback/&response_type=code&scope={scope}&force_verify=true'
    return HttpResponseRedirect(url)
def refresh_token_scope(request):
    client_id = os.environ.get('TWITCH_APP_ID', None)
    helix_scopes = list(TwitchAPIScope.objects.filter(required=True).values_list('scope', flat=True))
    eventsub_scopes = list(TwitchEventSubSubscription.objects.filter(active=True).values_list('scope_required', flat=True))
    scopes = list(set(((settings.TOKEN_SCOPES + eventsub_scopes) + helix_scopes)))
    scopes = list(filter((lambda x: (x is not None)), scopes))
    scope = ' '.join(scopes)
    url = f'https://id.twitch.tv/oauth2/authorize?client_id={client_id}&redirect_uri={settings.BASE_URL}/twitch-callback/&response_type=code&scope={scope}&force_verify=true'
    return HttpResponseRedirect(url)