Skip to main content
Question

How do I download files using a User Token instead of an Application Token?

  • October 18, 2017
  • 0 replies
  • 202 views

Hello. I sometimes write scripts that manipulate QuickBase record attachments from outside of quickbase. Usually just like a "curl" request from the command line.
In the past the instructions outlined here have worked very well. I just get an API ticket from API_Authenticate (using my username and password):,

https://mysite.quickbase.com/db/main?a=API_Authenticate&username=me@mysite.org&password=XXXXXXXXXX

then run a command like this from the terminal:

curl https://mysite.quickbase.com/up/XXXXXXXXX/a/rXXXXX/eXX/v0?ticket=<authentication_ticket_from_API_Authenticate> > Desktop/mydownload.pdf

And the file in question appear in mydownload.pdf on my Desktop

BUT HERE'S THE PROBLEM: I'm trying to use User Tokens now, since they're just much nicer and easier to keep track of, but as far as I can tell there is no way to get an authentication ticket when exclusively using User Tokens for authentication. For example, running something like:

https://mysite.quickbase.com/up/XXXXXXXXX/a/rXXXXX/eXX/v0?usertoken=<my_user_token>

gives me a message that "User token is invalid" (despite the fact that it is a known working user token). Running the following API_Authenticate call in order to try to get a ticket from the user token:

https://mysite.quickbase.com/db/main?a=API_Authenticate&usertoken=<my_user_token>

gives me the following error:

<qdbapi>

  <action>API_Authenticate</action>
  <errcode>3</errcode>
  <errtext>Insufficient permissions</errtext>
  <errdetail>You don't have sufficient permissions to access that page. User Tokens cannot be used to call this API</errdetail>
  <username>me</username></qdbapi>

And this is a token that is associated with an account that has full access to the app, so I am confident it's not a permissions thing.

Are there any potential workarounds to this?
This topic has been closed for replies.

  • Registered
  • October 18, 2017
I think you need to create an apptoken. 
http://help.quickbase.com/user-assistance/#app_tokens.html

  • Author
  • Registered
  • October 18, 2017
I have tried that - when I run this:

https://mysite.quickbase.com/up/XXXXXXXXX/a/rXXXXX/eXX/v0?apptoken=my_apptoken

It just takes me to a quickbase sign-in page. When I try to get an application ticket using an apptoken, like so:

https://mysite.quickbase.com/db/main?a=API_Authenticate&apptoken=my_apptoken

I get an error message telling me that I "must specify a valid username and password or a valid ticket to use API_Authenticate

  • Registered
  • October 18, 2017
Shaund,
User tokens are a substitute for authentication, as well as the apptoken.  You need to assign the user token to the app you want to access. You don't need to authenticate to the app to use api calls - as long as you have the user token in the parameters...
Here's a complete write up on user tokens:
https://help.quickbase.com/api-guide/create_user_tokens.html
Good luck..
Neil

  • Author
  • Registered
  • October 19, 2017
Thank you. I've checked, and I do indeed have the user token assigned to the app that i want to download files attachments from.

Now that I have that, how do I download files from the app using it?

I can confirm that the usertoken query param does work when using the URL for a file attachment returned from a doQuery operation.

Not sure this helps for your use case.

  • Registered
  • November 29, 2018
Hello Daniel, 

I'm trying this https://target_domain.quickbase.com/up/DBID/a/rRID/eFID/vVID?usertoken=<mysusertoken>;  in an HTPP request, GET method and is not working for me.  If I try without the user token is redirecting me to a sign in page. Could you please specify a bit more how are doing it using doQuery operation? I've just read in the API GUIDE, API_DoQuery section that 'Field types as File Attachment can't be used as a query's matching value' 

An example or any help will be much appreciated.

Kind regards

  • Registered
  • November 29, 2018
Hello again,

Forget about my last comment I made it work. The problem was I forgot to add the user token to the
right application.

I confirm this works using http request and get method 

https://target_domain.quickbase.com/up/DBID/a/rRID/eFID/vVID?usertoken=<mysusertoken>

Kind regards,