Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

com.workrefined:dropbox-boot

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.workrefined:dropbox-boot

Glue module for using Dropbox Core API with Spring Boot, using autowiring and externalized configuration of access information

  • 0.1.1
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

README

This module provides a simple factory for the Dropbox core API client using spring-boot conventions. The idea is to save the developer from having to a find their own conventions for storing the access token.

It allows a single DbxClient per running app, so this isn't for you if you want multiple users to connect to their dropbox account.

Installation

Add the dependency to your pom.xml

<dependency>
	<groupId>com.workrefined</groupId>
	<artifactId>dropbox-boot</artifactId>
	<version>0.1.0</version>
</dependency>

Add the following properties to your application.properties

com.workrefined.dropbox.clientIdentifier=Your app name
com.workrefined.dropbox.appKey=XXXXXXXXXX
com.workrefined.dropbox.appSecret=YYYYYYYYYYY
com.workrefined.dropbox.accessToken=ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

Now your class is really easy

public class FooService {
	@Autowired DropboxClientFactory dropboxClientFactory;
	
	public void someMethod() throws DbxException {
		DbxClient dropbox = dropboxClientFactory.getClient();
		DbxEntry.WithChildren children = dropbox.getMetadataWithChildren("/");	
		...
	}
}

Getting your access token

One of the tricks of using the Core API is getting your access token. Since this use case deals with a single Dropbox user per app instance, it's doubtful you want a whole interactive UI to manage (and protect) for going through the whole Oauth granting flow.

The Dropbox Core API getting started docs show how to get an access token, but how would you put that in a real app?

This leverages the Spring Boot CLI, make sure you have that installed

Create a file named dropbox_prompt.groovy

import com.workrefined.dropbox.DropboxConfigForm;

@Component
@Grab(group='com.workrefined', module='dropbox-boot', version='0.1.0')
public class MainController implements CommandLineRunner {
 
	@Autowired DropboxConfigForm form
	
	public void run(String... args) throws Exception {
		form.prompt()
	}
}

Now run it, using

spring run dropbox_prompt.groovy

It will look something like this

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.2.3.RELEASE)
....
How should this app identify itself to Dropbox?
My App
Enter your app key
XXXXXXXXXX
Enter your app secrete
YYYYYYYYYY
Now go to: 
	https://www.dropbox.com/1/oauth2/authorize?locale=en_US&client_id=XYXYXYXYX&response_type=code
(you might have to login first) then click "allow"2. Click "Allow"
Enter the authcode here
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
Excellent! You linked account: Ben Johnson
Here is a fragment of values you can enter into your application.properties file
########
com.workrefined.dropbox.clientIdentifier=My App
com.workrefined.dropbox.appKey=XXXXXXXXXX
com.workrefined.dropbox.appSecret=YYYYYYYYYY
com.workrefined.dropbox.accessToken=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
#########

Save the following file to Install the Spring Boot CLI

http://docs.spring.io/spring-boot/docs/1.2.3.RELEASE/reference/htmlsingle/#getting-started-installing-the-cli

FAQs

Package last updated on 28 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc