Quick Base Discussions

Expand all | Collapse all

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

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

    Posted 10-17-2017 20:03
    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?


  • 2.  RE: How do I download files using a User Token instead of an Application Token?

    Bronze
    Contributor
    Posted 10-17-2017 20:06
    I think you need to create an apptoken. 
    http://help.quickbase.com/user-assistance/#app_tokens.html


  • 3.  RE: How do I download files using a User Token instead of an Application Token?

    Posted 10-17-2017 20:25
    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


  • 4.  RE: How do I download files using a User Token instead of an Application Token?

    Posted 10-17-2017 21:20
    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


  • 5.  RE: How do I download files using a User Token instead of an Application Token?

    Posted 10-19-2017 01:39
    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?


  • 6.  RE: How do I download files using a User Token instead of an Application Token?

    Posted 05-08-2018 07:12
    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.


  • 7.  RE: How do I download files using a User Token instead of an Application Token?

    Posted 11-29-2018 14:51
    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


  • 8.  RE: How do I download files using a User Token instead of an Application Token?

    Posted 11-29-2018 15:02
    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,