Is it possible to hack the Force CLI to pass login info in from the command line?

Looking at the code here, you can see that its using oauth2 to get a token.

Maybe there is a URL hack to pass the Username/Password into the oAuth URL? Of course you would still have to grant permissions the first time around.

1 Answer 1


I don't see how it would be possible with the current pre-compiled binaries that are available for download; however, the latest and greatest source code has the ability to do what you want without any sort of hacking.

Take a look at the login.go file usage. There are login options that take a user name and password that use SOAP behind the scenes to log in:

force login un pw # log in using SOAP
force login test un pw # log in using SOAP to sandbox org

You can issue the command.

$ force login un pw

Make sure that you include the security token on the end of the password if you are outside of your trusted/whitelisted IP ranges.

I had to compile from source as documented in the Hacking section (copied at the end of this answer for reference), since there are not precompiled binaries. Here is what I had to do on my Windows machine.

The Hacking directions

# set these environment variables in your startup scripts
export GOPATH=~/go
export PATH="$GOPATH/bin:$PATH"

# download the source and all dependencies
$ go get -u github.com/heroku/force
$ cd $GOPATH/src/github.com/heroku/force

# to compile and test modifications
$ go get .
$ force 

Following the Hacking directions results in a force executable file (force.exe) being created in the ~/go/bin directory. You can then use that executable.

Once I did that I was able to sucessfully login using the command:

force login [email protected] mypasswordMySecurityToken
  • 1
    great answer. I pretty much just discovered the exact same thing and was coming here to answer my own question. You did a way better job than I would have though
    – NSjonas
    Mar 4, 2014 at 5:12
  • This inspired me to document how to start off hacking the CLI in this post. Mar 5, 2014 at 13:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .