Skip to content

Instantly share code, notes, and snippets.

@jeffdonthemic jeffdonthemic/app.rb
Last active Sep 3, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.