cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you interested in hearing how one of our Community members uses Dropbox for sailing trips? Read all about it 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 get an acces token without a login?

How can i get an acces token without a login?

Alex_Ch
Helpful | Level 5
Go to solution

why am I using Dropbox?

I´m developing a project with react. It's pretty simple, just a form where ussers send a pdf file. The thing I want to do is just that the ussers send their file and its uploaded to my dropbox account in its app folder. 

 

what im having trouble with:

I were testing with the generated token in app console, but i need a way to have an access token. How could i get an access token witout a login?, i just need that the ussers send the files to my app folder in my dropbox

 

I apologize for my poor choice of words, I`m new in this topic

1 Accepted Solution

Accepted Solutions

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

Hi @Alex_Ch,

Since you want to access your own account (not user's accounts), the best way would be to implement the entire communication to your Dropbox account (or the communication management, at least) on your server side. In such a way you can use pre-generated refresh token usable to refresh your access token (generation whenever needed - something performed automatically when official SDK is in use). There is no way access token to be generated completely without user confirmation (the your confirmation in particular case - your account is the target), but once refresh token is generated you can use it without further interaction from your side or your site's users.

One scenario is on post the pdf, it flows to your site and next from your site to Dropbox (i.e. your site behave like a proxy). Other scenario is on user intent to post, on your site a temporary upload link to be generated and the pdf to be uploaded directly to Dropbox (without passing through your site) using this link. In the both cases you don't expose any credentials to the user's browser, something that should be followed (or is advisable, at least).

Hope this gives direction.

View solution in original post

19 Replies 19

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

Hi @Alex_Ch,

Since you want to access your own account (not user's accounts), the best way would be to implement the entire communication to your Dropbox account (or the communication management, at least) on your server side. In such a way you can use pre-generated refresh token usable to refresh your access token (generation whenever needed - something performed automatically when official SDK is in use). There is no way access token to be generated completely without user confirmation (the your confirmation in particular case - your account is the target), but once refresh token is generated you can use it without further interaction from your side or your site's users.

One scenario is on post the pdf, it flows to your site and next from your site to Dropbox (i.e. your site behave like a proxy). Other scenario is on user intent to post, on your site a temporary upload link to be generated and the pdf to be uploaded directly to Dropbox (without passing through your site) using this link. In the both cases you don't expose any credentials to the user's browser, something that should be followed (or is advisable, at least).

Hope this gives direction.

Greg-DB
Dropbox Staff
Go to solution

@Alex_Ch I see Здравко already offered some helpful guidance.

 

For more information on the OAuth flow, for retrieving a refresh token, refer to the following resources:

And the documentation for the endpoint for generating a temporary upload link can be found here:

Alex_Ch
Helpful | Level 5
Go to solution

excuse me but, how could i use the http request to refresh the access token in the sdk for javascript? 

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

@Alex_Ch wrote:

excuse me but, how could i use the http request to refresh the access token in the sdk for javascript? 


You can use raw http request, but you don't need to do that. As I said you can use SDK and in every SDK (including Dropbox Javascript SDK) are equivalent calls. It's your decision what you will use (depending on your development environment server side - you haven't mentioned what are you using there till now).

 

Add: You may have skipped what I wrote above and I will repeat again. When your use some SDK (doesn't matter what exactly) the refreshing is performed automatic internally. You don't need to do more that proper client object initialization. Everything else is the same.

Greg-DB
Dropbox Staff
Go to solution

@Alex_Ch Здравко is correct, the official Dropbox SDKs, such as the Dropbox JavaScript SDK, will handle the refresh for you automatically as long as you supply the necessary credentials (refresh token, app key, etc.). You can find an example of that for the Dropbox JavaScript SDK here.

Alex_Ch
Helpful | Level 5
Go to solution

Hello again, excuse my delay.

I`ve been studying the documentation and the SDK example, and I have a question.

I`m not get used to using express js, so I'm a little bit lost with that. Where does the parameter "code" comes from? I`ve tried with the token I already have, but I get a 400 code.


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

Hi @Alex_Ch,

You don't need to embed this part of the code; focus on the line that Greg enlightened and shows how you can set refresh token (one of the possible ways). You can take a look here how you can get all needed by hand; it's one time action. The last action described in the post, I linked to (the only repeatable), gets performed by the SDK internally.

Greg-DB
Dropbox Staff
Go to solution

@Alex_Ch As Здравко said, you shouldn't be embedding and re-using the 'code'. The 'code' value is the "authorization code", which can only be used once. You should instead store and re-use the "refresh token" once you have it.

Alex_Ch
Helpful | Level 5
Go to solution

Ok, I´ve been testing and I think I got it.

Just one more question, how do I pre-generate the refresh token? (I think I should start with that, I apologize for that)

Need more support?
Who's talking

Top contributors to this post

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