Skip to content

Instantly share code, notes, and snippets.

@jeffdonthemic
Last active September 3, 2019 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffdonthemic/089f676bfcaa0ab6c16df87c3d0e54e1 to your computer and use it in GitHub Desktop.
Save jeffdonthemic/089f676bfcaa0ab6c16df87c3d0e54e1 to your computer and use it in GitHub Desktop.
Refresh Token from Salesforce
begin
require 'sinatra'
require 'omniauth'
require 'omniauth-salesforce'
rescue LoadError
require 'rubygems'
require 'sinatra'
require 'omniauth'
require 'omniauth-salesforce'
end
set :port, 3000
use Rack::Session::Cookie
use OmniAuth::Builder do
provider :salesforce, ENV['TEST_SALESFORCE_CLIENT_ID'], ENV['TEST_SALESFORCE_CLIENT_SECRET']
end
get '/' do
<<-HTML
<h1>Sign into Salesforce and get a refresh token. Try it... it's fun!</h1>
<a href='/auth/salesforce'>Sign into Salesforce</a> with your xxx@sriracha.trailhead.com account
HTML
end
get '/auth/:name/callback' do
auth = request.env['omniauth.auth']
puts auth
"Here is your handy-dandy refresh token: #{auth['credentials']['refresh_token']}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment