Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Jagan Tirumalai
2 years agoExplorer | Level 4
Dropbox generate Auth Token thru java
Hi,
I am able to generate Access Token manually thru the dropbox website which is working fine. But expires after a few hours, Is there any method in Java that can generate access token program...
DB-Des
Dropbox Community Moderator
2 years agoHi Jagan Tirumalai,
You would need to use getter methods to retrieve the values of the respective properties. Following the example provided previously (for PKCE flow), it is returning a DbxAuthFinish object. That object contains getters for the properties that could be returned in the response — one of them being the access_token.
In this specific case, the corresponding getter method to retrieve the access token would be getAccessToken().
The following lines of code provide an example of one way the access_token could be retrieved:
// Assign the DbxAuthFinish object to a variable
DbxAuthFinish authFinish = authorize();
// Use the getAccessToken() method to retrieve the access_token and save to a variable
String accessToken = authFinish.getAccessToken();
To retrieve the refresh_token, for offline access, you would use the getRefreshToken() method.
Jagan Tirumalai
2 years agoExplorer | Level 4
Got it. Thank you once again for being patient in answering my questions. The method getAccessToken() worked fine as expected.
Is this part automated in pkceAuthorize.java ?
String authorizeUrl = pkceWebAuth.authorize(webAuthRequest);
System.out.println("1. Go to " + authorizeUrl);
System.out.println("2. Click \"Allow\" (you might have to log in first).");
System.out.println("3. Copy the authorization code.");
System.out.print("Enter the authorization code here: ");
Currently i am copying the authorizeUrl and pasting it into the web browser and copying back the authorization code and pasting it into my java application and then the application runs fine.
- DB-Des2 years ago
Dropbox Community Moderator
Jagan Tirumalai, the example of the PKCE auth flow is meant to serve as a reference implementation. It's designed to help developers understand how PKCE works in practice but may not be suitable for all use cases or production environments without modification.
We recommend reviewing the code and adapting it to fit your specific needs, including automating the auth flow.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If 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, Facebook or Instagram.
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!