<commit_before>import flask
import datetime
import plotly
import requests


def login():
    authorization_header = flask.request.headers.get('Authorization')
    oauth_token = authorization_header.split('Bearer ')[1]
    res = requests.get(
        '{}/v2/users/current'.format(
            plotly.config.get_config()['plotly_api_domain']
        ),
        headers={
            'Authorization': authorization_header
        }
    )
    res.raise_for_status()
    response = flask.Response(
        res.json(),
        status=res.status_code
    )
    # TODO - set path appropriately
    response.set_cookie(
        'plotly_dash_oauth_token',
        value=oauth_token,
        max_age=None
    )
    return response


def check_view_access(oauth_token, fid):
    res = requests.get(
        '{}/v2/files/{}'.format(
            plotly.config.get_config()['plotly_api_domain'],
            fid
        ),
        headers={
            'Authorization': 'Bearer {}'.format(oauth_token)
        }
    )
    if res.status_code == 200:
        return True
    elif res.status_code == 404:<commit_msg>:bug: return login response as json<commit_after>import flask
import datetime
import json
import plotly
import requests


def login():
    authorization_header = flask.request.headers.get('Authorization')
    oauth_token = authorization_header.split('Bearer ')[1]
    res = requests.get(
        '{}/v2/users/current'.format(
            plotly.config.get_config()['plotly_api_domain']
        ),
        headers={
            'Authorization': authorization_header
        }
    )
    res.raise_for_status()
    response = flask.Response(
        json.dumps(res.json()),
        mimetype='application/json',
        status=res.status_code
    )
    # TODO - set path appropriately
    response.set_cookie(
        'plotly_dash_oauth_token',
        value=oauth_token,
        max_age=None
    )
    return response


def check_view_access(oauth_token, fid):
    res = requests.get(
        '{}/v2/files/{}'.format(
            plotly.config.get_config()['plotly_api_domain'],
            fid
        ),
        headers={
            'Authorization': 'Bearer {}'.format(oauth_token)
        }
    )
    if res.status_code == 200:
        return True
    elif res.status_code == 404:
{'fraction_non_alphanumeric': 0.11496270293988592, 'fraction_numerical': 0.007898200965335674, 'mean_word_length': 2.2995658465991315, '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': '3356635', 'n_tokens_mistral': 707, 'n_tokens_neox': 688, 'n_words': 121}