We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

pabloAlvarezmv's avatar
pabloAlvarezmv
Explorer | Level 3
9 years ago
Solved

Problems with DbxAuthFinish in Java DropBox V 3.0.3

Hello, when i try to connect to the Java App i've created for the first time using no redirect requesting i get a fatal error just on the DbxAuthFinish, giving me a java.lang.ExceptionInitializerError. I checked out many times but my code is still the same as the example found in the API tutorials. Here is my code:

	String accessToken = "";
		String userLocale = null;
		DbxRequestConfig requestConfig = new DbxRequestConfig("text-edit/0.1",userLocale);
	     DbxAppInfo appInfo = new DbxAppInfo(APP_KEY,SECRET_KEY);
	     DbxWebAuth auth = new DbxWebAuth(requestConfig, appInfo);
	     DbxWebAuth.Request requestAuth = DbxWebAuth.newRequestBuilder().withNoRedirect().build(); 	
	     String authorizeUrl = auth.authorize(requestAuth);
	     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.");
	    
		//Abrimos el enlace de autenticación del paciente en la carpeta de DropBox
		try {
			URL authenticationURL = new URL(authorizeUrl);
			Desktop.getDesktop().browse(authenticationURL.toURI());
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String code = JOptionPane.showInputDialog(this.ventanaControlada, "Inserta el codigo de verificación.");
		System.out.println(code);
		code = code.trim();
		
		try {			
			 DbxAuthFinish authFinish = auth.finishFromCode(code);
	         
			accessToken = authFinish.getAccessToken();
			
		} catch (Exception e) {
		

Thanks for all, i hope you can find any response soon! 

  • Greg-DB's avatar
    Greg-DB
    9 years ago
    Did you add dropbox-core-sdk-3.0.3.jar or dropbox-core-sdk-3.0.3-sources.jar? You should add dropbox-core-sdk-3.0.3.jar to use the library.

6 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    Can you share the full error/stack trace? Thanks in advance!
  • pabloAlvarezmv's avatar
    pabloAlvarezmv
    Explorer | Level 3
    9 years ago
    Exception in thread "main" java.lang.ExceptionInInitializerError
    	at com.dropbox.core.DbxRequestUtil.buildUserAgentHeader(DbxRequestUtil.java:146)
    	at com.dropbox.core.DbxRequestUtil.addUserAgentHeader(DbxRequestUtil.java:131)
    	at com.dropbox.core.DbxRequestUtil.startPostRaw(DbxRequestUtil.java:228)
    	at com.dropbox.core.DbxRequestUtil.startPostNoAuth(DbxRequestUtil.java:211)
    	at com.dropbox.core.DbxRequestUtil$2.run(DbxRequestUtil.java:389)
    	at com.dropbox.core.DbxRequestUtil.runAndRetry(DbxRequestUtil.java:434)
    	at com.dropbox.core.DbxRequestUtil.doPostNoAuth(DbxRequestUtil.java:386)
    	at com.dropbox.core.DbxWebAuth.finish(DbxWebAuth.java:401)
    	at com.dropbox.core.DbxWebAuth.finish(DbxWebAuth.java:383)
    	at com.dropbox.core.DbxWebAuth.finishFromCode(DbxWebAuth.java:295)
    	at Control.ImageDropBoxController.StartFirstConnection(ImageDropBoxController.java:154)
    	at Control.ImageDropBoxController.main(ImageDropBoxController.java:171)
    Caused by: java.lang.RuntimeException: Error loading version from resource "sdk-version.txt": Text doesn't follow expected pattern: "${project.version}"
    	at com.dropbox.core.DbxSdkVersion.loadVersion(DbxSdkVersion.java:66)
    	at com.dropbox.core.DbxSdkVersion.<clinit>(DbxSdkVersion.java:17)
    	... 12 more

    ImageDropBoxController it's the class where im testing the connection.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    Thanks! It looks like the contents of the sdk-version.txt file aren't in the format expected. It should be a version number, instead of "${project.version}".

    How did you install the SDK? Did you successfully build the SDK first? This value should get expanded when you do so:

    https://github.com/dropbox/dropbox-sdk-java#building-from-source

    Alternatively, you can download the built library from Gradle or Maven by specifying it as a dependency as shown here:

    https://github.com/dropbox/dropbox-sdk-java#setup
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    Did you add dropbox-core-sdk-3.0.3.jar or dropbox-core-sdk-3.0.3-sources.jar? You should add dropbox-core-sdk-3.0.3.jar to use the library.
  • pabloAlvarezmv's avatar
    pabloAlvarezmv
    Explorer | Level 3
    9 years ago

    Yeah, i had both of them, i removed the dropbox-core-sd-3.0.3-sources.jar and now works perfectly fine. Thanks for all! :grin:

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 2 hours ago
410 Following

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 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!