Help articles
Authenticating the CLI when running remotely
Use robot tokens instead
This method is no longer supported. Use a robot token instead.
As the authentication process for the CLI relies on you interacting with the API through a browser, this can be a problem when running the CLI on a remote server. However if you follow this recipe, you will be able to successfully authenticate the remote installed CLI.
- Go to
https://api.sanity.io/v1/auth/login/github?type=token&origin=http://localhost
Exchangegithubforgoogleif you prefer that. You don't need anything actually running on localhost. - Pick out the value of the
sidparameter in the return url trying to redirect to localhost. - Load
https://api.sanity.io/v1/auth/fetch?sid=xxxxusing thesidvalue from above. - Get the
tokenproperty from the result. - Create the file
~/.config/sanity/config.jsonon the remote server in the home directory for the user running the CLI.
Set the file contents to the following, and replace "yyyy" with the token value from above:
{
"authToken": "yyyy",
"authType": "normal"
}Was this page helpful?