daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest May 17th, 2018 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require 'sinatra'
  2. require 'koala'
  3. require 'time'
  4.  
  5. $client_id = "LOLZ"
  6. $redirect_uri = "MOARLOLZ"
  7. $app_secret = "SECRETSQUIRREL"
  8.  
  9. $day = 86400
  10.  
  11. include Koala
  12. enable :sessions
  13.  
  14. get '/' do
  15.   if session['access_token']
  16.     'You are logged in! <a href="/logout">Logout</a>'
  17.   else
  18.     'You are not logged in...'
  19.     '<a href="/login">Login</a>'
  20.   end
  21. end
  22.  
  23. get '/login' do
  24.   session['oauth'] = Koala::Facebook::OAuth.new($client_id, $app_secret, $redirect_uri)
  25.   redirect session['oauth'].url_for_oauth_code(:permissions => "read_stream,publish_stream")
  26. end
  27.  
  28. get '/logout' do
  29.   session['oauth'] = nil
  30.   session['access_token'] = nil
  31.   redirect '/'
  32. end
  33.  
  34. get '/callback' do
  35.   session['access_token'] = session['oauth'].get_access_token(params[:code])
  36.   redirect '/'
  37. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top