
Enables access to Dropbox, Google Drive, and OneDrive through a single library. Features include lightweight integration, app folder access, and plans for mobile and desktop support.
Multiple clouds, one Kotlin Multiplatform bridge. Currently supporting Android, web and desktop ( JVM), but iOS support is planned.
This library is not yet stable. The API will change and docs may be outdated.
Limited access scopes by using app folders are preferred by the library wherever possible.
| Mobile (Android) |
Mobile (iOS) |
Desktop (JVM) |
Web (JS/WASM) |
|
|---|---|---|---|---|
| Dropbox | ✅ | ⏳ | ✅ | ✅ |
| Google Drive | ✅ | ⏳ | ✅ | ✅ |
| Microsoft OneDrive | ✅ | ⏳ | ✅ | ✅ |
✅ = Supported.
⏳ = Planned.
See Compatibility.md for important remarks about each service.
See Compatibility.md for details.
The library is published to Maven Central.
dependencies {
implementation("nl.jacobras:cloudbridge:0.5.0")
}The main entry point is CloudBridge.dropbox(), CloudBridge.googleDrive() or
CloudBridge.oneDrive().
Here's an example with Dropbox. First instantiate the service:
val service = CloudBridge.dropbox()Then, have the user authenticate.
Desktop
val authServer = LocalAuthenticationServer()
// Build auth URL and open it in the browser
val url = service.authenticate(
authServer = authServer,
clientId = "yourClientId",
onSuccess = { token ->
service.setToken(token)
TODO("Store the token locally")
}
)
openBrowser(url)Web
// Always call this:
val token = service.completeAuthentication()
if (token != null) {
service.setToken(token)
}
// When user wants to authenticate:
val uri = service.authenticate(
clientId = "yourClientId",
redirectUri = "yourRedirectUri"
)
window.location.href = uriAndroid (Dropbox & OneDrive)
Open the auth URL in a Custom Tab and capture the redirect via a deep link (intent-filter).
Then exchange the authorization code for a token:
// When user wants to authenticate:
val url = service.authenticate(
clientId = "yourClientId",
redirectUri = "yourRedirectUri" // e.g. a custom scheme like "com.example://cloudbridge-auth"
)
CustomTabsIntent.Builder().build().launchUrl(context, url.toUri())
// In your Activity's onNewIntent (and onCreate), call:
val token = service.completeAuthentication(
clientId = "yourClientId",
redirectUri = "yourRedirectUri" // Needs to match the uri passed into authenticate()
)Note: Google Drive on web doesn't need any parameters passed into completeAuthentication().
Android (Google Drive)
Google no longer supports custom-scheme redirects on Android, so the library has to use Google Identity Services instead. Also see Underlying dependencies.
val googleDriveAuthenticator = GoogleDriveAuthenticator(
activity = this,
onSuccess = { token -> TODO() },
onDenied = { TODO() },
onFailure = { error -> TODO() }
)
Securely store the token and pass it to the constructor of the service to use it.
val service = CloudBridge.dropbox(token)
try {
service.listFiles()
} catch (e: CloudServiceException) {
// Handle...
}The library only supports limited/private app folders, no full access.
The library prefers to work with IDs over paths.
Only one account per service is supported as of now.
id and path variables are typed as much as possible, to prevent accidental mix-ups.
Dropbox will throw 409 when it can't find a path. Other services throw
404 CloudBridge turns them both into CloudServiceException.NotFoundException.
Feel free to open an issue if you have a different use case for any of these.
All service APIs were written from scratch to avoid dependencies on SDKs.
This library uses:
Only on Android:
play-services-auth) for Google Drive authorization.Multiple clouds, one Kotlin Multiplatform bridge. Currently supporting Android, web and desktop ( JVM), but iOS support is planned.
This library is not yet stable. The API will change and docs may be outdated.
Limited access scopes by using app folders are preferred by the library wherever possible.
| Mobile (Android) |
Mobile (iOS) |
Desktop (JVM) |
Web (JS/WASM) |
|
|---|---|---|---|---|
| Dropbox | ✅ | ⏳ | ✅ | ✅ |
| Google Drive | ✅ | ⏳ | ✅ | ✅ |
| Microsoft OneDrive | ✅ | ⏳ | ✅ | ✅ |
✅ = Supported.
⏳ = Planned.
See Compatibility.md for important remarks about each service.
See Compatibility.md for details.
The library is published to Maven Central.
dependencies {
implementation("nl.jacobras:cloudbridge:0.5.0")
}The main entry point is CloudBridge.dropbox(), CloudBridge.googleDrive() or
CloudBridge.oneDrive().
Here's an example with Dropbox. First instantiate the service:
val service = CloudBridge.dropbox()Then, have the user authenticate.
Desktop
val authServer = LocalAuthenticationServer()
// Build auth URL and open it in the browser
val url = service.authenticate(
authServer = authServer,
clientId = "yourClientId",
onSuccess = { token ->
service.setToken(token)
TODO("Store the token locally")
}
)
openBrowser(url)Web
// Always call this:
val token = service.completeAuthentication()
if (token != null) {
service.setToken(token)
}
// When user wants to authenticate:
val uri = service.authenticate(
clientId = "yourClientId",
redirectUri = "yourRedirectUri"
)
window.location.href = uriAndroid (Dropbox & OneDrive)
Open the auth URL in a Custom Tab and capture the redirect via a deep link (intent-filter).
Then exchange the authorization code for a token:
// When user wants to authenticate:
val url = service.authenticate(
clientId = "yourClientId",
redirectUri = "yourRedirectUri" // e.g. a custom scheme like "com.example://cloudbridge-auth"
)
CustomTabsIntent.Builder().build().launchUrl(context, url.toUri())
// In your Activity's onNewIntent (and onCreate), call:
val token = service.completeAuthentication(
clientId = "yourClientId",
redirectUri = "yourRedirectUri" // Needs to match the uri passed into authenticate()
)Note: Google Drive on web doesn't need any parameters passed into completeAuthentication().
Android (Google Drive)
Google no longer supports custom-scheme redirects on Android, so the library has to use Google Identity Services instead. Also see Underlying dependencies.
val googleDriveAuthenticator = GoogleDriveAuthenticator(
activity = this,
onSuccess = { token -> TODO() },
onDenied = { TODO() },
onFailure = { error -> TODO() }
)
Securely store the token and pass it to the constructor of the service to use it.
val service = CloudBridge.dropbox(token)
try {
service.listFiles()
} catch (e: CloudServiceException) {
// Handle...
}The library only supports limited/private app folders, no full access.
The library prefers to work with IDs over paths.
Only one account per service is supported as of now.
id and path variables are typed as much as possible, to prevent accidental mix-ups.
Dropbox will throw 409 when it can't find a path. Other services throw
404 CloudBridge turns them both into CloudServiceException.NotFoundException.
Feel free to open an issue if you have a different use case for any of these.
All service APIs were written from scratch to avoid dependencies on SDKs.
This library uses:
Only on Android:
play-services-auth) for Google Drive authorization.