tl;dr - I'm confused about a) why I can't access the our new Sandbox form the API and b) why rather than getting an authorisation error I'm getting redirected.
We've just set up a new SF sandbox, and I've been struggling to get API access to it working in our Rails/Restforce app. The old sandbox was working fine with the following ENV vars set:
SALESFORCE_HOST=test.salesforce.com
SALESFORCE_USERNAME=<name>
SALESFORCE_PASSWORD=<password>
SALESFORCE_SECURITY_TOKEN=<token>
SALESFORCE_INSTANCE_URL=https://cs88.lightning.force.com
SALESFORCE_CLIENT_ID=<id>
SALESFORCE_CLIENT_SECRET=<secret>
SALESFORCE_API_VERSION=38.0
For the new one I've set the same username and password as I use to log in, reset and copied the security token, and set the client ID and client secret respectively from the 'Consumer Key' and 'Consumer Secret' fields on the 'Manage Connected Apps' page. The SF host I took to be the URL I visit in order to log in - in the new case 'founderspledge--fptestdata.lightning.force.com'.
The Salesforce instance URL I wasn't sure about, but found something that looked analogous in the Login URL section of the user account I use to log in, to wit founderspledge--fptestdata.cs105.my.salesforce.com - so I've set that to https://cs105.lightning.force.com, but I also tried the old version just in case.
For API version I followed the classic section of this page: https://help.salesforce.com/articleView?id=000199268&type=1 (Lightning force version didn't work), which showed it as 43.0, which I've set that field to.
But when I call any query on the Restforce client, the response is a 302 redirect (full response object at bottom) rather than eg a 401 (interestingly, Restforce didn't seem to expect this, since it crashes with undefined method []' for nil:NilClass (NoMethodError)
- I've raised that as a separate issue on the gem).
I'm not sure what to make of this. Does it mean I've got one of the authorisation details wrong? If so, does anything I've written give a clue as to which? If not... what's happening?
#<Faraday::Response:0x00007fa626ecdff0
@env=
#<struct Faraday::Env
method=:post,
body=nil,
url=#<URI::HTTPS https://founderspledge--fptestdata.lightning.force.com/services/oauth2/token>,
request=#<struct Faraday::RequestOptions params_encoder=nil, proxy=nil, bind=nil, timeout=nil, open_timeout=nil, boundary=nil, oauth=nil>,
request_headers={"User-Agent"=>"Faraday v0.10.1", "Content-Type"=>"application/x-www-form-urlencoded"},
ssl=
#<struct Faraday::SSLOptions
verify=true,
ca_file=nil,
ca_path=nil,
verify_mode=nil,
cert_store=nil,
client_cert=nil,
client_key=nil,
certificate=nil,
private_key=nil,
verify_depth=nil,
version=nil>,
parallel_manager=nil,
params=nil,
response=#<Faraday::Response:0x00007fa626ecdff0 ...>,
response_headers=
{"date"=>"Thu, 09 Aug 2018 12:31:03 GMT",
"strict-transport-security"=>"max-age=31536001; includeSubDomains",
"public-key-pins-report-only"=>
"pin-sha256=\"9n0izTnSRF+W4W4JTq51avSXkWhQB8duS2bxVLfzXsY=\"; pin-sha256=\"5kJvNEMw0KjrCAu7eXY5HZdvyCS13BbA0VJG1RSP91w=\"; pin-sha256=\"njN4rRG+22dNXAi+yb8e3UMypgzPUPHlv4+foULwl1g=\"; max-age=86400; includeSubDomains; report-uri=\"https://calm-dawn-26291.herokuapp.com/hpkp-report/nullm\";",
"expect-ct"=>"max-age=0; report-uri=\"https://calm-dawn-26291.herokuapp.com/Expect-CT-report/nullm\";",
"x-content-type-options"=>"nosniff",
"x-xss-protection"=>"1; mode=block",
"content-security-policy"=>"upgrade-insecure-requests",
"x-robots-tag"=>"none",
"cache-control"=>"no-cache,must-revalidate,max-age=0,no-store,private",
"set-cookie"=>"BrowserId=bil03ftqTBSzJHokseRFdw;Path=/;Domain=.force.com;Expires=Mon, 08-Oct-2018 12:31:03 GMT;Max-Age=5184000",
"expires"=>"Thu, 01 Jan 1970 00:00:00 GMT",
"location"=>"https://founderspledge--FPTestData.cs105.my.salesforce.com/services/oauth2/token",
"content-length"=>"0"},
status=302,
reason_phrase="Found">,
@on_complete_callbacks=[]>