<commit_before>class AccessTokensController < ApplicationController
  before_filter :authenticate_user!

  def redirect
    puts "Recieved code #{params[:code]}"
    post_params = {'client_id' => '5723', 'client_secret' => APP_CONFIG["stack_api"]["secret"], 'code' => params[:code], 'redirect_uri' => 'http://flag-eventually.erwaysoftware.com/access_tokens/redirect'}

    token_request = Net::HTTP.post_form(URI.parse("https://stackexchange.com/oauth/access_token"), post_params)
    begin
      token = token_request.body.scan(/access_token=(.*)$/)[0][0]
      current_user.access_token = token
      current_user.save!
      redirect_to :success
    rescue
      render :text => "Something went wrong" and return
    end
  end

  def begin<commit_msg>Error handling<commit_after>class AccessTokensController < ApplicationController
  before_filter :authenticate_user!

  def redirect
    puts "Recieved code #{params[:code]}"
    post_params = {'client_id' => '5723', 'client_secret' => APP_CONFIG["stack_api"]["secret"], 'code' => params[:code], 'redirect_uri' => 'http://flag-eventually.erwaysoftware.com/access_tokens/redirect'}

    token_request = Net::HTTP.post_form(URI.parse("https://stackexchange.com/oauth/access_token"), post_params)
    begin
      token = token_request.body.scan(/access_token=(.*)$/)[0][0]
      current_user.access_token = token
      current_user.save!
      redirect_to :success
    rescue => exception
      render :text => "Something went wrong: #{exception.backtrace}" and return
    end
  end

  def begin
{'fraction_non_alphanumeric': 0.1390685640362225, 'fraction_numerical': 0.007761966364812419, 'mean_word_length': 4.48581560283688, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 2, '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': '7476250', 'n_tokens_mistral': 482, 'n_tokens_neox': 475, 'n_words': 88}