Last active
May 4, 2023 12:35
-
-
Save jeffdonthemic/856328ffafa2cd705068 to your computer and use it in GitHub Desktop.
Restforce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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