Can I authenticate to Quickbase API with wget or curl?

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered
I can authenticate with API_Authenticate using exactly the same parameters in the url when I try through a web browser.  However, if I try the same exact url through a tool like wget or curl, I get an error #20 back from Quickbase which indicates that the username and/or password is invalid.

What am I doing wrong?  Sample url I'm passing below...

https://ourdomain.quickbase.com/db/main?a=API_authenticate&username=myemail@domain.com&password=Pass...
Photo of Brian

Brian

  • 0 Points

Posted 2 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,044 Points 20k badge 2x thumb
Using Chrome follow these steps:

1) Open Dev Tools (F12) and enter this command into the Console using your credentials:

fetch("https://YOURSUBDOMAIN.quickbase.com/db/main?a=API_Authenticate&username=MYUSERNAME&password=MY...

Note the fetch command needs a balanced quote around the URL string (the forum is clipping the text).

2) Move to the Network tab and hover your mouse over the URL displayed as "main?a=API_Authenticate ..."

3) Right click mouse and select Copy | Copy as cURL (cmd). You will get something like this in the clibpoard:

curl "https://YOURSUBDOMAIN.quickbase.com/db/main?a=API_Authenticate^&username=MYUSERNAME^&password=MYPASS..." -H "Accept: */*" -H "Connection: keep-alive" -H "Accept-Encoding: gzip, deflate, sdch, br" -H "Referer: https://YOURSUBDOMAIN.quickbase.com/db/main" -H "Accept-Language: en-US,en;q=0.8" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36" --compressed

Again the forum may be clipping some of the text.

4) Remove the carets before &username and &password.

5) If you paste the resulting command into a command shell you should get an XML response that contains a ticket

<?xml version="1.0" ?>
<qdbapi>
        <action>API_Authenticate</action>
        <errcode>0</errcode>
        <errtext>No error</errtext>
        <ticket>8_bmfb4yyni_bsy9ur_z6_a_r4rm3ic8765akd8fy8jubjwe9wjqspthnchzwwdsh3dxj3czkihiq</ticket>
        <userid>51084879.bdbt</userid>
</qdbapi>

6) You can probably shorten the curl command by dropping some headers and experiment with other Copy options to  see what works for your particular scenario. I have long since stopped using curl and wget with QuickBase since all the scripting languages support better abstractions.
Photo of Brian

Brian

  • 0 Points
Dan, thank you very much!  This worked exactly as you suggested.
Photo of Brian

Brian

  • 0 Points
It seems that curl wanted quotes around the url.  So, for example, curl "https://...&hours=1"  worked and properly retrieved a new ticket.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,044 Points 20k badge 2x thumb
This is more of a general procedure to get the curl command for any network request without having to read the curl manual.