<commit_before>from django.conf import settings
from oauth2client import client, crypt


def verify_token(token_string):
    """Verify the given Google auth token string & return the 'sub' portion
    as stated in the docs. See: https://goo.gl/MIKN9X

    Returns None upon failure.

    """
    token = None
    valid_accounts = ['accounts.google.com', 'https://accounts.google.com']
    client_id = settings.GOOGLE_OAUTH_CLIENT_ID
    try:
        idinfo = client.verify_id_token(token, client_id)
        # TODO: If multiple clients access the backend server:
        # if idinfo['aud'] not in [ANDROID_ID, IOS_ID, client_id]:
        #     raise crypt.AppIdentityError("Unrecognized client.")
        if idinfo['iss'] not in valid_accounts:
            raise crypt.AppIdentityError("Wrong issuer.")

        # Save the portion we want to keep.
        token = idinfo['sub']

    except crypt.AppIdentityError:  # Invalid token
        token = None

    return token<commit_msg>typo fix; we need to validate the correc auth token<commit_after>from django.conf import settings
from oauth2client import client, crypt


def verify_token(token_string):
    """Verify the given Google auth token string & return the 'sub' portion
    as stated in the docs. See: https://goo.gl/MIKN9X

    Returns None upon failure.

    """
    token = None
    valid_accounts = ['accounts.google.com', 'https://accounts.google.com']
    client_id = settings.GOOGLE_OAUTH_CLIENT_ID

    try:
        idinfo = client.verify_id_token(token_string, client_id)
        # TODO: If multiple clients access the backend server:
        # if idinfo['aud'] not in [ANDROID_ID, IOS_ID, client_id]:
        #     raise crypt.AppIdentityError("Unrecognized client.")
        if idinfo['iss'] not in valid_accounts:
            raise crypt.AppIdentityError("Wrong issuer.")

        # Save the portion we want to keep.
        token = idinfo['sub']

    except crypt.AppIdentityError:  # Invalid token
        token = None

    return token
{'fraction_non_alphanumeric': 0.09113545816733068, 'fraction_numerical': 0.00199203187250996, 'mean_word_length': 2.962524654832347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '7294709', 'n_tokens_mistral': 594, 'n_tokens_neox': 576, 'n_words': 182}