Skip to content

Instantly share code, notes, and snippets.

@jeffdonthemic
Last active May 4, 2023 12:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffdonthemic/856328ffafa2cd705068 to your computer and use it in GitHub Desktop.
Save jeffdonthemic/856328ffafa2cd705068 to your computer and use it in GitHub Desktop.
Restforce
require 'restforce'
# set default org with sfdx
# sfdx config set target-org=<some username or org alias>
# grab the access token & instance url from the default scratch org using sfdx
org = JSON.parse(`sfdx org display --json`)
client = Restforce.new(
oauth_token: org['result']['accessToken'],
instance_url: org['result']['instanceUrl'],
api_version: '57.0'
)
puts "Username: #{org['result']['username']}"
puts "Oauth token: #{org['result']['accessToken']}"
puts '-------------------------------------'
accounts = client.query("SELECT Id, Name FROM Contact LIMIT 2")
puts accounts.first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment