"sf api request rest" does not refresh session token when required #3176
Open
Description
Note
Before you submit your issue, make sure that:
- You're using the latest version of Salesforce CLI.
- You've searched both open and closed issues for related posts.
- You've used the
doctor
command to diagnose common issues.- You understand that GitHub Issues don't adhere to any agreement or SLA.
- If you require immediate assistance, use official channels such as Salesforce Customer Support.
Summary
When I run sf api request rest '/services/data/v60.0/' --method GET
, it works great most of the time.
But if the CLI's access token has expired and need to be refreshed, this command just fails instead of refreshing the token.
Obviously, I know that this is a beta command, but it'll be good to know it's on the issue list for when this command becomes fully released.
Steps To Reproduce
In a project where the access token has expired, run sf api request rest '/services/data/v60.0/' --method GET
before running any other CLI command.
This will fail, if you run another CLI command against your org, then retry the api request, it will succeed.
Expected result
CLI returns the API description
{
"metadata": "/services/data/v60.0/metadata",
"eclair": "/services/data/v60.0/eclair",
"folders": "/services/data/v60.0/folders",
"jsonxform": "/services/data/v60.0/jsonxform",
"appMenu": "/services/data/v60.0/appMenu",
...
Actual result
Session error returned:
[
{
"message": "Session expired or invalid",
"errorCode": "INVALID_SESSION_ID"
}
]
Additional information
System Information
{
"architecture": "darwin-arm64",
"cliVersion": "@salesforce/cli/2.71.6",
"nodeVersion": "node-v22.12.0",
"osVersion": "Darwin 23.6.0",
"rootPath": "/Users/aidan/.local/share/sf/client/2.71.6-df87f59",
"shell": "zsh",
"pluginVersions": [
"@oclif/plugin-autocomplete 3.2.14 (core)",
"@oclif/plugin-commands 4.1.14 (core)",
"@oclif/plugin-help 6.2.19 (core)",
"@oclif/plugin-not-found 3.2.31 (core)",
"@oclif/plugin-plugins 5.4.22 (core)",
"@oclif/plugin-search 1.2.17 (core)",
"@oclif/plugin-update 4.6.18 (core)",
"@oclif/plugin-version 2.2.18 (core)",
"@oclif/plugin-warn-if-update-available 3.1.28 (core)",
"@oclif/plugin-which 3.2.21 (core)",
"@processity/cli-performance-testing 0.0.9 (user) published 125 days ago (Wed Sep 11 2024)",
"@salesforce/cli 2.71.6 (core)",
"apex 3.6.8 (core)",
"api 1.3.2 (core)",
"auth 3.6.82 (core)",
"community 3.3.7 (user) published 32 days ago (Sat Dec 14 2024) (latest is 3.3.8)",
"data 3.13.5 (core)",
"deploy-retrieve 3.16.0 (core)",
"info 3.4.29 (core)",
"limits 3.3.43 (core)",
"marketplace 1.3.7 (core)",
"org 5.2.11 (core)",
"packaging 2.9.7 (core)",
"schema 3.3.45 (core)",
"settings 2.4.9 (core)",
"sobject 1.4.46 (core)",
"telemetry 3.6.27 (core)",
"templates 56.3.34 (core)",
"trust 3.7.51 (core)",
"user 3.6.5 (core)",
"@salesforce/sfdx-scanner 4.7.0 (user) published 77 days ago (Tue Oct 29 2024) (latest is 4.8.0)"
]
}