<commit_before>#!/usr/bin/python

import json
import requests

class GitHubAuthenticator(object):
    """ Class provides OAuth authentization via GitHub API"""

    def __init__(self, client_id, client_secret, access_token_url):
        self.client_id = client_id
        self.client_secret = client_secret
        self.access_token_url = access_token_url

    def retrieve_access_token(self, code):
        """ 
        Method retrieves access token to GitHub API
        for provided code.

        @param code: code sent by GitHub after user granted
         access privileges to application
        @type code: str
        @return: access token, that can be used to 
          access GitHub profile of user
        @rtype: str| None
        """

        if not code:
            #TODO raise exception here
            return ""
    
        params = {"client_id": self.client_id,
                  "client_secret": self.client_secret,
                  "code": code }
        paramsJson = json.dump(params)

        headers = {"Content-Type": "application/json",
                   "Accept": "application/json" }

        access_response = requests.post(self.access_token_url,
            data=paramsJson, headers=headers)
        if access_response.status != 200:
            #TODO raise exception
            return ""

        respondJson = access_response.json()
        return respondJson["access_token"]<commit_msg>Repaired bugs in auth module<commit_after>#!/usr/bin/python

import json
import requests

class GitHubAuthenticator(object):
    """ Class provides OAuth authentization via GitHub API"""

    def __init__(self, client_id, client_secret, access_token_url):
        self.client_id = client_id
        self.client_secret = client_secret
        self.access_token_url = access_token_url

    def retrieve_access_token(self, code):
        """ 
        Method retrieves access token to GitHub API
        for provided code.

        @param code: code sent by GitHub after user granted
         access privileges to application
        @type code: str
        @return: access token, that can be used to 
          access GitHub profile of user
        @rtype: str| None
        """

        if not code:
            #TODO raise exception here
            return ""
    
        params = {"client_id": self.client_id,
                  "client_secret": self.client_secret,
                  "code": code }
        paramsJson = json.dumps(params)

        headers = {"Content-Type": "application/json",
                   "Accept": "application/json" }

        access_response = requests.post(self.access_token_url,
            data=paramsJson, headers=headers)
        if access_response.status_code != 200:
            #TODO raise exception
            return ""

        respondJson = access_response.json()
        return respondJson["access_token"]
{'fraction_non_alphanumeric': 0.08011145942180425, 'fraction_numerical': 0.0020898641588296763, 'mean_word_length': 2.1525795828759606, 'pattern_counts': {'":': 10, '<': 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': '1253106', 'n_tokens_mistral': 769, 'n_tokens_neox': 726, 'n_words': 217}