<commit_before>import inspect

from .scopes import get_userinfo_by_scopes


def process_id_token(payload, user, scope=None):
    if scope is None:
        # HACK: Steal the scope argument from the locals dictionary of
        # the caller, since it was not passed to us
        scope = inspect.stack()[1][0].f_locals.get('scope', [])

    payload.update(get_userinfo_by_scopes(user, scope))<commit_msg>Add username to ID Token<commit_after>import inspect

from .scopes import get_userinfo_by_scopes


def process_id_token(payload, user, scope=None):
    if scope is None:
        # HACK: Steal the scope argument from the locals dictionary of
        # the caller, since it was not passed to us
        scope = inspect.stack()[1][0].f_locals.get('scope', [])

    payload.update(get_userinfo_by_scopes(user, scope))
    payload['preferred_username'] = user.username
{'fraction_non_alphanumeric': 0.09479768786127167, 'fraction_numerical': 0.004624277456647399, 'mean_word_length': 3.9485714285714284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4473172', 'n_tokens_mistral': 266, 'n_tokens_neox': 261, 'n_words': 79}