<commit_before>class FacebookController < ApplicationController

  def connect
    ap redirect_uri
    redirect_to client.web_server.authorize_url(:redirect_uri => redirect_uri, :scope => 'offline_access')
  end

  def callback
    @access_token = client.web_server.get_access_token(params[:code], :redirect_uri => redirect_uri)
    @user = JSON.parse(@access_token.get('/me'))

    render :index
  end

  def client
    OAuth2::Client.new(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_API_SECRET'], :site => 'https://graph.facebook.com')
  end

  def redirect_uri
    uri = URI.parse(request.url)
    uri.path = '/facebook/callback'
    uri.query = nil
    uri.to_s
  end
      
end<commit_msg>create account<commit_after>class FacebookController < ApplicationController

  def connect
    ap redirect_uri
    redirect_to client.web_server.authorize_url(:redirect_uri => redirect_uri, :scope => 'offline_access')
  end

  def callback
    access_token = client.web_server.get_access_token(params[:code], :redirect_uri => redirect_uri)
    #user = JSON.parse(access_token.get('/me'))

    @account = FacebookAccount.new(
      :access_token => access_token.token,
      :user_id => current_user.id)

    notice = @account.save ? 'You successfully authorized your Facebook account.' : 
                             'There was an issue authorizing your Facebook account. Please try again.'

    redirect_to user_root_path, :notice => notice
  end

  def client
    OAuth2::Client.new(ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_API_SECRET'], :site => 'https://graph.facebook.com')
  end

  def redirect_uri
    uri = URI.parse(request.url)
    uri.path = '/facebook/callback'
    uri.query = nil
    uri.to_s
  end
      
end
{'fraction_non_alphanumeric': 0.11163062536528345, 'fraction_numerical': 0.0011689070718877848, 'mean_word_length': 3.61455525606469, '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': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2749691', 'n_tokens_mistral': 542, 'n_tokens_neox': 527, 'n_words': 111}