<commit_before>#!ruby

require 'sinatra'
require 'multi_json'
require 'ringcentral_sdk'

# Enter config in .env file

client = RingCentralSdk::REST::Client.new do |config|
  config.dotenv = true
end

get '/' do
  erb :index, locals: {
    app_key: config.app.key,
    authorize_url: client.authorize_url,
    redirect_uri: client.app_config.redirect_url
  }
end

get '/oauth' do
  code = params.key?('code') ? params['code'] : ''
  token_json = ''
  if code
    token = client.authorize_code(code)
    token_json = MultiJson.encode(token.to_hash, pretty: true)
  end
  erb :oauth, locals: {
    code: code,
    token: token_json
  }
end<commit_msg>update OAuth2 Sinatra demo<commit_after>#!ruby

require 'sinatra'
require 'multi_json'
require 'ringcentral_sdk'

# Enter config in .env file

client = RingCentralSdk::REST::Client.new do |config|
  config.load_env = true
end

get '/' do
  erb :index, locals: {
    app_key: client.config.app_key,
    authorize_url: client.authorize_url,
    redirect_uri: client.config.redirect_url
  }
end

get '/oauth' do
  code = params.key?('code') ? params['code'] : ''
  token_json = ''
  if code
    token = client.authorize_code(code)
    token_json = MultiJson.encode(token.to_hash, pretty: true)
  end
  erb :oauth, locals: {
    code: code,
    token: token_json
  }
end
{'fraction_non_alphanumeric': 0.1232876712328767, 'fraction_numerical': 0.00076103500761035, 'mean_word_length': 3.7992700729927007, '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': '2114719', 'n_tokens_mistral': 486, 'n_tokens_neox': 477, 'n_words': 112}