cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you interested in learning how media industry leaders use Dropbox Replay? Register for our webinar here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I simply upload files via API without manually generating an access token?

How can I simply upload files via API without manually generating an access token?

playstationmobile
Explorer | Level 4
Go to solution

* I have the app secret and key
* I had some script working but the access token is short lived, as I used the one I generated from the console
* I cant find any API info on how to generate an access token? All I see is stuff about where you generate some code and then you have to open a webpage and enter the code.......how is my planned cron job going to run if I have to involve opening a browser and entering an access code etc etc

1 Accepted Solution

Accepted Solutions

Здравко
Legendary | Level 20
Go to solution

Hi @playstationmobile,

As seems, it passed long time since you last used your application console to generate long lived access token. Years have passed since this feature has been deprecated and already dropped. If you have some long lived access token, it'll work still, but all new issued access token (it doesn't matter how exactly issued) are mandatory short lived (they have few hours live - typically 4 hours or so).

You can still have long term access (in similar way as has been before), but you need refresh token (one more in addition to access token). The refresh token is long lived and doesn't expire itself. For a possible way (one of number of options) to receive and use refresh token, you may take a look here. Just implement the steps in your application' workflow and all should look the same as before. 😉 You will need to implement in the application the last (repetitive) step only, where new access token will comes up as result of refresh token usage. If you're using some of official Dropbox SDKs, the only thing you need is proper client object initialization with everything needed (including refresh token, app key, and optionally app secret - optional when you used PKCE OAuth flow otherwise mandatory). Dropbox SDK has implemented the last repetitive step already, so you don't need to change anything more; just continue using your code as before.

Hope this gives direction.

View solution in original post

4 Replies 4

Здравко
Legendary | Level 20
Go to solution

Hi @playstationmobile,

As seems, it passed long time since you last used your application console to generate long lived access token. Years have passed since this feature has been deprecated and already dropped. If you have some long lived access token, it'll work still, but all new issued access token (it doesn't matter how exactly issued) are mandatory short lived (they have few hours live - typically 4 hours or so).

You can still have long term access (in similar way as has been before), but you need refresh token (one more in addition to access token). The refresh token is long lived and doesn't expire itself. For a possible way (one of number of options) to receive and use refresh token, you may take a look here. Just implement the steps in your application' workflow and all should look the same as before. 😉 You will need to implement in the application the last (repetitive) step only, where new access token will comes up as result of refresh token usage. If you're using some of official Dropbox SDKs, the only thing you need is proper client object initialization with everything needed (including refresh token, app key, and optionally app secret - optional when you used PKCE OAuth flow otherwise mandatory). Dropbox SDK has implemented the last repetitive step already, so you don't need to change anything more; just continue using your code as before.

Hope this gives direction.

playstationmobile
Explorer | Level 4
Go to solution

@ Здравко

Thank you. So just to confirm, there is no automated way like I said in my original post right? Being able to run a script where you have app secret and key, and getting tokens is not possible without having to open browsers and deal with auth codes, etc etc. Your link, shows the first step involving opening a web browser in order to get tokens and....well im basically trying to run a cron script daily to back up a folder on a server to my Dropbox.

Здравко
Legendary | Level 20
Go to solution

@playstationmobile wrote:

... So just to confirm, there is no automated way like I said in my original post right? ...


Hm..🤔 Actually as I said you can do whatever you was doing before in the same automated way. If there is something you cannot understand, just clarify you question (or read more careful). 🙋

 


@playstationmobile wrote:

... Being able to run a script where you have app secret and key, and getting tokens is not possible without having to open browsers and deal with auth codes, etc etc. ...


Ok. When were you able to run your script with just app key and app secret? Has such way been ever possible? 🤷 Nothing changed in this regards. 🙂 I don't know where your imagination is flying. Your application was possible to work without browser open and it's still able to do the same. To continue does this it needs one more token though. That's it.

 


@playstationmobile wrote:

... Your link, shows the first step involving opening a web browser in order to get tokens ...


Yes, in the similar way as you needed to open web browser before to take long lived access token. It was needed just once, right? 🧐 Correct me if you used some other way I have no any idea about. It's the same way you need to get refresh token once and use it further without need your browser anymore. Of course the way (exact steps) has changed - it's different token.

Adapt your script (as I said before) and it will continue work in the same way.

Good luck.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Здравко Legendary | Level 20
  • User avatar
    playstationmobile Explorer | Level 4
What do Dropbox user levels mean?