cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Learn more about how Connie, a member of the Community, uses Dropbox 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: 

Problems with DbxAuthFinish in Java DropBox V 3.0.3

Problems with DbxAuthFinish in Java DropBox V 3.0.3

pabloAlvarezmv
Explorer | Level 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! 

1 Accepted Solution

Accepted Solutions

Re: Problems with DbxAuthFinish in Java DropBox V 3.0.3

Greg-DB
Dropboxer
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.

View solution in original post

6 Replies 6

Re: Problems with DbxAuthFinish in Java DropBox V 3.0.3

Greg-DB
Dropboxer
Can you share the full error/stack trace? Thanks in advance!

Re: Problems with DbxAuthFinish in Java DropBox V 3.0.3

pabloAlvarezmv
Explorer | Level 3
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.

Re: Problems with DbxAuthFinish in Java DropBox V 3.0.3

Greg-DB
Dropboxer
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

Re: Problems with DbxAuthFinish in Java DropBox V 3.0.3

pabloAlvarezmv
Explorer | Level 3

I just got the Java API from the webpage https://github.com/dropbox/dropbox-sdk-java/releases/tag/v3.0.3

and added the jar to my Eclipse project. Then build and configure the path's to the .jar's and compile it. Works fine just until the line marked on the stacktrace error i pasted above. 

Re: Problems with DbxAuthFinish in Java DropBox V 3.0.3

Greg-DB
Dropboxer
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.

View solution in original post

Re: Problems with DbxAuthFinish in Java DropBox V 3.0.3

pabloAlvarezmv
Explorer | Level 3

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:

Poll
Are you starting new work habits this year?
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?