cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more 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: 

Downloading and uploading files from dropbox .net sdk using my own account

Downloading and uploading files from dropbox .net sdk using my own account

sisrael1
New member | Level 2

Hi im new to developing with dropbox and im having a hard finding the following info. im using dropbox .net sdk to upload and download images from my own account i set up a little test using the generated access token from developer app portal, this token is short lived (starts with sl.) i've seen based on some question that dropbox no longer offers long lived tokens, so how can i implement a refresh token process without any interaction? 

 

heres the test code for refrence

 

 

try
        {
            var filePath = "PATH";
            var dbx = new DropboxClient("sl.TOKEN_HERE"); // Replace with your actual access token

            var response = dbx.Files.DownloadAsync(filePath).Result;

            if (response.Response.IsFile)
            {
                var fileContent = response.GetContentAsByteArrayAsync().Result;
               
                string base64String = Convert.ToBase64String(fileContent);
                return Ok(base64String);
            }
            else
            {
                // Handle the case where the response is not a file (e.g., it's a folder).
                return BadRequest("Requested item is not a file.");
            }
        }
        catch (Exception e)
        {
            throw new InternalServerException(e.Message);
        }

 

 

1 Accepted Solution

Accepted Solutions

Здравко
Legendary | Level 20

@sisrael1 wrote:

..., so how can i implement a refresh token process without any interaction? 

...


Hi @sisrael1,

Without any interaction - impossible. Unfortunately, Dropbox doesn't provide a way to receive refresh token as it was for long lived access token (not yet at least). You need to perform one interaction, at least, either within the application or by hands - some initial (interactive) steps. You may take a look here of how you can get refresh token (there entire process is shown; you don't need the last steps, since they are implemented in SDK) and after that just initialize your Dropbox client object with that tokens and keys (not just access token only like you are doing right now).

Hope this helps.

View solution in original post

4 Replies 4

Здравко
Legendary | Level 20

@sisrael1 wrote:

..., so how can i implement a refresh token process without any interaction? 

...


Hi @sisrael1,

Without any interaction - impossible. Unfortunately, Dropbox doesn't provide a way to receive refresh token as it was for long lived access token (not yet at least). You need to perform one interaction, at least, either within the application or by hands - some initial (interactive) steps. You may take a look here of how you can get refresh token (there entire process is shown; you don't need the last steps, since they are implemented in SDK) and after that just initialize your Dropbox client object with that tokens and keys (not just access token only like you are doing right now).

Hope this helps.

sisrael1
New member | Level 2

Thank you for you're response i have read that post before asking my question, the difficulty im having is the following, im only using my own user account in dropbox to store images and its being done by my backend (c# web api) so this auth flow as described in that post needs to happen when and where exactly? i hope you understand my difficulty here from this poorly written reply

Здравко
Legendary | Level 20

Hi again @sisrael1,

Yes, I understood what you mean. 🙂

 


@sisrael1 wrote:

... so this auth flow as described in that post needs to happen when and where exactly? ...


At any moment before you're going to use your system (let's say right now would be fine). That flow needs to be performed a single time only and, as mentioned there, refresh token doesn't expire. So,... your system will be ready for use for... ever. 😉 (or till revoke)

Hope this clarifies matter.

 

PS: I forgot to mention that you can execute the commands wherever convenient for you (let's say on the machine you are posting now would be fine).

sisrael1
New member | Level 2

thank you i didnt get that part that its a one time action needed not every time i want to use dropbox

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    sisrael1 New member | Level 2
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?