cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right 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 lifetime Access Token

How can i get lifetime Access Token

Ghost Mjrm
Explorer | Level 4

i have android app connected to my Dropbox folder using access token but every 4 hour should i edit my code and input the new access token is there any method to make the app working 24h without any interact from me

and fix the message that show access token error uploading to Dropbox: expired access token

 

 

private void uploadToDropbox(File photoFile) {
if (photoFile == null || !photoFile.exists()) {
runOnUiThread(() -> Toast.makeText(MainActivity.this, "Error: Photo file does not exist", Toast.LENGTH_SHORT).show());
return;
}

DbxRequestConfig config = DbxRequestConfig.newBuilder("Decamera").build();
DbxClientV2 client = new DbxClientV2(config, DROPBOX_ACCESS_TOKEN);

try {
String remotePath = "/Decamera/" + photoFile.getName();

try (InputStream in = new FileInputStream(photoFile)) {
client.files().uploadBuilder(remotePath)
.withMode(WriteMode.ADD)
.uploadAndFinish(in);

runOnUiThread(() -> Toast.makeText(MainActivity.this, "Photo uploaded to Dropbox", Toast.LENGTH_SHORT).show());
}

} catch (Exception e) {
e.printStackTrace();
runOnUiThread(() -> Toast.makeText(MainActivity.this, "Error uploading to Dropbox: " + e.getMessage(), Toast.LENGTH_SHORT).show());
}
}
private static final String DROPBOX_ACCESS_TOKEN = my access token

 

41 Replies 41

Ghost Mjrm
Explorer | Level 4

i have remove the offline access type and same problem successfully upload to dropbox but there is no nothing in the dropbox app

private void initiateDropboxAuthorization() {
// Construct the Dropbox authorization URL
String authorizationUrl = "https://www.dropbox.com/oauth2/authorize" +
"?client_id=" + DROPBOX_APP_KEY +
"&response_type=code" +
"&state=myState" + // Replace with your own state
"&redirect_uri=" + DROPBOX_REDIRECT_URI;

// Open the authorization URL in a web browser or WebView
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(authorizationUrl));
startActivity(browserIntent);
}

Здравко
Legendary | Level 20

No, 'offline' access type just adds refresh token to response, nothing else! Something that you're ignoring in your code completely so far. So that cannot be a reason. Are you sure you have uploaded to the same account? :upside_down_face:

Ghost Mjrm
Explorer | Level 4
Yeah im sure but its possible that the obtained access token belong to another person ? Not me

Здравко
Legendary | Level 20

In other words, you're not sure - make it sure! :winking_face:

Ghost Mjrm
Explorer | Level 4
I have recheck that the app key app secret belong to me it cannot be to another one but i think the authorisation had a configuration problem what do you think

Здравко
Legendary | Level 20

I think you should NOT mess the application ownership with the account one! They are different things in general (can coincide of course), but you assume they are the same thing always - something wrong. I'm pretty sure your account is different (my questions above are rhetoric). :winking_face:

Ghost Mjrm
Explorer | Level 4

i did not understand what you mean but you make me remember about the account by mention you the account word up there

so i opened the app and instead of using a new account in the app ive used the one that belong to me the original one 

but in this case when someone used my app should sign in also in my account when press on the oauth 2 operation to obtain new access token

Здравко
Legendary | Level 20

:beaming_face_with_smiling_eyes: In this case (following your words) when someone uses your application should sign in in the same account when pass on the OAuth 2 operation where will look for the file uploaded (no in other account, like you did). :winking_face:

Ghost Mjrm
Explorer | Level 4
I thought that the user can use any email to upload the file to my dropbox server app because simply using my app key and app secret that I configured in my code

Здравко
Legendary | Level 20

Yes, user can do it and the file will get to the account matching this email (whoever is the owner). The same like when you use the official Dropbox application. Where a file put in Dropbox folder goes? 🧐 To your Dropbox account or to account own by some of the application' developers (i.e. Dropbox staff)? :thinking_face::grinning_face_with_smiling_eyes:

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Ghost Mjrm Explorer | Level 4
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?