Forum Discussion

RileyL's avatar
RileyL
New member | Level 2
2 years ago
Solved

Durable or Offline OAth Token for RPA Use? (accessing own account only)

I am building a robotic process automation (RPA) using ZeroWork and JavaScript.  I successfully programmed the RPA to upload a file to Dropbox via the API, but I cannot find a way to get a durable OAuth token.  I can test it with sl. tokens, but they expire quickly, and since this is fully run on the RPA, there is no app or user interaction -- just the RPA communicating with the API.

I get the reason for the short expirations and I am fine with coding in token refreshes, if I could just get the offline token I need to do it.  We are only accessing our own Dropbox account and files, so we don't need other users to do any authorization of their accounts.

Is there a solution for this?  All of the Dropbox OAuth documentation I can find appears to assume that we're building apps for other users to interact with and are blind to things like RPA file handling.  We just want to be able to access our own files with the RPA.

Thanks for any help you can offer.


  • RileyL wrote:

    ...
    I get the reason for the short expirations and I am fine with coding in token refreshes, if I could just get the offline token I need to do it.  We are only accessing our own Dropbox account and files, so we don't need other users to do any authorization of their accounts.
    ...


    Hi RileyL,

    Whenever you need long term to access an account (doesn't matter only your own or for multiple user accounts), you need to perform offline OAuth flow. By now, Dropbox provide only access token (that's short lived) on the applications panel, but no way you get refresh token (the long lived one) in the same way. There are different ways to do so. One possible way to get by hand a refresh token and how you could automatic refresh your access token could be seen here. Only the last step there need to be coded and used repeatably, all other steps are one time only.

    Hope this helps.

6 Replies

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    2 years ago

    RileyL wrote:

    ...
    I get the reason for the short expirations and I am fine with coding in token refreshes, if I could just get the offline token I need to do it.  We are only accessing our own Dropbox account and files, so we don't need other users to do any authorization of their accounts.
    ...


    Hi RileyL,

    Whenever you need long term to access an account (doesn't matter only your own or for multiple user accounts), you need to perform offline OAuth flow. By now, Dropbox provide only access token (that's short lived) on the applications panel, but no way you get refresh token (the long lived one) in the same way. There are different ways to do so. One possible way to get by hand a refresh token and how you could automatic refresh your access token could be seen here. Only the last step there need to be coded and used repeatably, all other steps are one time only.

    Hope this helps.

  • RileyL's avatar
    RileyL
    New member | Level 2
    2 years ago

    This is FANTASTIC!  Thank you!  One time hurdles are no problem if they produce a durable solution.  You are a life saver!

    I am off to try this method now and will report back.

  • RileyL's avatar
    RileyL
    New member | Level 2
    2 years ago

    Hey, thanks again for your help.
    At this stage:

    I am getting this error:
    Invoke-WebRequest : Parameter cannot be processed because the parameter name 'u' is ambiguous. Possible matches
    include: -UseBasicParsing -Uri -UseDefaultCredentials -UserAgent.
    At line:1 char:128
    + ... i5_3bN9Q -d grant_type=authorization_code -u m78 ...
    + ~~
    + CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    2 years ago

    Hi again RileyL,

    The example there uses cURL command. This command is available for variety of platforms and free for use (also very powerful - I advise you use it for this and whatever else you would need). Of course, there are other commands that have their params and options. You CANNOT rely that different commands will have the same set of options and params!!! Since you use different way to perform the requests, adapt all options/params to your command syntax. In particular the param '-u' for cURL denotes BASIC authentication. All commands (all I have ever used at least) have such param; just use the correct one (if you don't like cURL). 😉

    Good luck.

  • RileyL's avatar
    RileyL
    New member | Level 2
    2 years ago

    Sorry for any confusion, the command I used was this one:

    curl https://api.dropbox.com/oauth2/token -d code=<received code> -d grant_type=authorization_code -u <App key>:<App secret>

    I put in my received code, app key, and app secret.  I opened a Windows Terminal window and pasted that command in, and it spit back that -u error.  I'm not super familiar with curl, but I will do some research to see what might be going wrong.

  • RileyL's avatar
    RileyL
    New member | Level 2
    2 years ago

    Sorry, I figured it out.  The Windows terminal was opening Powershell.  I ran the line in cmd.exe and it worked.  Thank you again!  

About Integrations

Find solutions to issues with third-party integrations from the Dropbox Community. Share advice and help members with their integration questions.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!