Is there anyway/endpoint to create access_token in code for Dropbox SDK authorization?

332 Views Asked by At

I am using dropbox javascript sdk for file uploads using following end points. For file below 150MB

/upload

For file above 150MB

  /files/upload_session/start 
  /files/upload_session/append_v2

For Authorization, I am using the following code for now.

const ACCESS_TOKEN = 'my_access_token_created_manualy_from_app_console';
var dbx = new Dropbox.Dropbox({ accessToken: ACCESS_TOKEN, refresh_token });

Now I don't want to go to the app console every now and then to get access token. Is there any way I could handle it in my code? Any API/ajax request to get access token in response to app_key and app_secret?

1

There are 1 best solutions below

2
On

Getting a Dropbox access token for a user's account always requires some initial manual interaction from the user to authorize the app in some way. This cannot be done entirely programmatically. For the developer's own account, such as in your case, you can generate an access token on the App Console. For arbitrary end-users, this is instead processed via the OAuth app authorization flow.

You can refer to the OAuth Guide and authorization documentation for more information. For the Dropbox JavaScript SDK in particular, there's an example of processing the OAuth flow here.