We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
Reshma
3 years agoExplorer | Level 3
is there any Java sdk method to generate access token on the run by taking app key and app secret??
Hello Dropbox team,
As Access token is expiring every 4 hours, we have to regenerate them every 4 hrs. This is becoming difficult to update the access code in my script manually. I'm looking for a Java SDK method that generate access token automatically every 4 hours by taking app key/app secret as input parameters. Could you suggest any sdk method or code sample that I can use to generate access token on the run in my script using app key/app secret.
Any help would be highly appreciated !!
Hi again Reshma ,
Seems you have misunderstood me. You can't just place one type of token where other type is expected! In Java SDK a DbxCredential object should be used as a proxy (don't ask me why) for refresh token.
Hope it's a bit more clear now.
- ReshmaExplorer | Level 3
Thanks for the suggestion. I have created a Refresh token using this curl
curl https://api.dropbox.com/oauth2/token -d code=<receivedcode>-d grant_type=authorization_code -u <Appkey>:<Appsecret>
Then I have initialized/created drop box client object with Refresh token in place of access token
private static final String REFRESH_TOKEN = "<REDACTED_REFRESH_TOKEN> -u <REDACTED_APP_KEY>:<REDACTED_APP_SECRET>";
// Create drop box client
DbxRequestConfig config = DbxRequestConfig.newBuilder("dropbox/AppToCreateIT's").build();
DbxClientV2 client = new DbxClientV2(config, REFRESH_TOKEN);But unfortunately this dint work, it is throwing below error
Invalid authorization value in HTTP header "Authorization": "Bearer <REDACTED_REFRESH_TOKEN> -u <REDACTED_APP_KEY>:<REDACTED_APP_SECRET>". Expecting "Bearer <oauth2-access-token>".pardon If my understanding is wrong , could you please guide me with the exact steps to be followed?
I have taken the below reference to create dropbox client. instead of access token I have used refresh token as per your suggestion
GitHub - dropbox/dropbox-sdk-java: A Java library for the Dropbox Core API.
- ЗдравкоLegendary | Level 20
Hi again Reshma ,
Seems you have misunderstood me. You can't just place one type of token where other type is expected! In Java SDK a DbxCredential object should be used as a proxy (don't ask me why) for refresh token.
Hope it's a bit more clear now.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 2 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!