Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9098073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:16:29+00:00 2026-06-17T00:16:29+00:00

I am trying to use the Dropbox java API to have my java application

  • 0

I am trying to use the Dropbox java API to have my java application upload files. Somehow I end up with the same SSL error that I am not able to solve. Any suggestions?

I used this code (http://aaka.sh/patel/2011/12/20/authenticating-dropbox-java-api/)

    public class DropboxTest {

    // App key & secret that Dropbox's developer website gives your app
    private static final String APP_KEY = "myAppKey";
    private static final String APP_SECRET = "myAppSecret";
    // Define AccessType for DropboxAPI object
    final static private AccessType ACCESS_TYPE = AccessType.APP_FOLDER;
    private static DropboxAPI<WebAuthSession> mDBApi;

    public static void main(String[] args) throws Exception{

        // Initialize the goods/session
        AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
        WebAuthSession session = new WebAuthSession(appKeys, ACCESS_TYPE);

        // Initialize DropboxAPI object
        mDBApi = new DropboxAPI<WebAuthSession>(session);

        // Get ready for user input
        Scanner input = new Scanner(System.in);

        // Open file that stores tokens, MUST exist as a blank file
        File tokensFile = new File("TOKENS");

        System.out.println("Enter 'a' to authenticate, or 't' to test reauthentication: ");
        String command = input.next();

        if(command.equals("a")){

            try {

                // Present user with URL to allow app access to Dropbox account on
                System.out.println("Please go to this URL and hit \"Allow\": " + mDBApi.getSession().getAuthInfo().url);
                AccessTokenPair tokenPair = mDBApi.getSession().getAccessTokenPair();

                // Wait for user to Allow app in browser
                System.out.println("Finished allowing?  Enter 'next' if so: ");
                if(input.next().equals("next")){
                    RequestTokenPair tokens = new RequestTokenPair(tokenPair.key, tokenPair.secret);
                    mDBApi.getSession().retrieveWebAccessToken(tokens);
                    PrintWriter tokenWriter = new PrintWriter(tokensFile);
                    tokenWriter.println(session.getAccessTokenPair().key);
                    tokenWriter.println(session.getAccessTokenPair().secret);
                    tokenWriter.close();
                    System.out.println("Authentication Successful!");

                }

            } catch (DropboxException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        else if(command.equals("t")){

            Scanner tokenScanner = new Scanner(tokensFile);       // Initiate Scanner to read tokens from TOKEN file
            String ACCESS_TOKEN_KEY = tokenScanner.nextLine();    // Read key
            String ACCESS_TOKEN_SECRET = tokenScanner.nextLine(); // Read secret
            tokenScanner.close(); //Close Scanner 

            //Re-auth
            AccessTokenPair reAuthTokens = new AccessTokenPair(ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET);
            mDBApi.getSession().setAccessTokenPair(reAuthTokens);
            System.out.println("Re-authentication Sucessful!");

            //Run test command
            System.out.println("Hello there, " + mDBApi.accountInfo().displayName);

        }
    }
}

End up with an SSL exception:

com.dropbox.client2.exception.DropboxSSLException: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
    at com.dropbox.client2.RESTUtility.execute(RESTUtility.java:416)
    at com.dropbox.client2.RESTUtility.execute(RESTUtility.java:337)
    at com.dropbox.client2.RESTUtility.streamRequest(RESTUtility.java:192)
    at com.dropbox.client2.session.WebAuthSession.setUpToken(WebAuthSession.java:218)
    at com.dropbox.client2.session.WebAuthSession.getAuthInfo(WebAuthSession.java:158)
    at com.dropbox.client2.session.WebAuthSession.getAuthInfo(WebAuthSession.java:128)
    at DropboxTest.main(DropboxTest.java:45)
Caused by: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
    at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:397)
    at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
    at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:399)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:143)
    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:108)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
    at com.dropbox.client2.RESTUtility.execute(RESTUtility.java:385)
    ... 6 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:16:30+00:00Added an answer on June 17, 2026 at 12:16 am

    Figured it out. I was using OpenJDK on OSX.
    I ran the JVM with -Djavax.net.debug=ssl for debugging and ended up with the root exception being

    java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
    

    After some research I found the solution here:
    http://architecturalatrocities.com/post/19073788679/fixing-the-trustanchors-problem-when-running-openjdk-7

    Works fine now!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to upload files to dropbox in app I am making that
i'm trying use facebook API to upload photo in my fan page. I downloaded
I am trying use gem tire to search in my application. I have tables
I'm trying to use the Dropbox API for the first time, but i'm getting
I'm trying to have my App upload a file on Dropbox and I downloaded
Im trying use a Java annotation in a Groovy class but have trouble to
I am trying to upload file using dropbox api but following Code shows some
I am trying to create files in a Dropbox.com folder from a GAE application.
I am trying use a Java Uploader in a ROR app (for its ease
Hi I'm trying use a datepicker on a field I have. I'm trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.