You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

Jagan Tirumalai's avatar
Jagan Tirumalai
Explorer | Level 4
2 months ago

Dropbox generate Auth Token thru java

Hi,

 

I am able to generate Access Token manually thru the dropbox website which is working fine. But expires after a few hours, Is there any method in Java that can generate access token programmatically? I would like to test this out so that we can start doing uploads and downloads by generating access tokens.

 

 

 

 

  • DB-Des's avatar
    DB-Des
    Icon for Dropbox Engineer rankDropbox Engineer

    Hi Jagan Tirumalai,

     

    Even though Dropbox issues short-lived access tokens, apps can get long-term access by requesting "offline" access, in which case the app receives a "refresh token" that can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. Refresh tokens do not expire automatically and can be used repeatedly. You can find more information in the OAuth Guide and authorization documentation. There's a basic outline of processing this flow in this blog post which may serve as a useful example.

     

    For your use case, working with refresh tokens would be easier with our official Java SDK. Helper methods accept the refresh token, and manage this update of the short-lived access token for you.

     

    I hope you find this information helpful!

    • Jagan Tirumalai's avatar
      Jagan Tirumalai
      Explorer | Level 4

      Thank you very much for your response. I have generated an access code from oauth2. Its asking me to enter this code into CLIENTSDATA (which is the app i created in dropbox). I don't know where to enter this Access Code in ClientsData. Given below are the screenshots of the access code from OAUTH2 and ClientsData settings/permissions.  Where do i enter this access code in ClientsData settings/permissions?

       

       

      Spoiler
       

       

       

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        Jagan Tirumalai That "access code" is also known as the "authorization code". It should not be copied into the app's settings on the App Console; it should be copied back into the app itself. For example, refer to this line in the Java SDK example code that reads the authorization code back into the app so it can then finish the authorization flow.