https://github.com/darrarski/swift-dropbox-client
Basic Dropbox HTTP API client that does not depend on Dropbox's SDK
https://github.com/darrarski/swift-dropbox-client
cloud-file-system cloud-files dropbox dropbox-api dropbox-client oauth2 swift swift-package-manager
Last synced: 10 months ago
JSON representation
Basic Dropbox HTTP API client that does not depend on Dropbox's SDK
- Host: GitHub
- URL: https://github.com/darrarski/swift-dropbox-client
- Owner: darrarski
- License: mit
- Created: 2023-07-06T20:20:09.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-17T20:32:41.000Z (almost 3 years ago)
- Last Synced: 2025-07-20T15:06:36.845Z (11 months ago)
- Topics: cloud-file-system, cloud-files, dropbox, dropbox-api, dropbox-client, oauth2, swift, swift-package-manager
- Language: Swift
- Homepage:
- Size: 77.1 KB
- Stars: 5
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Swift Dropbox Client


Basic Dropbox HTTP API client that does not depend on Dropbox's SDK. No external dependencies.
- Authorize access
- List folder
- Get file metadata
- Upload file
- Download file
- Delete file
## 📖 Usage
Use [Swift Package Manager](https://swift.org/package-manager/) to add the `DropboxClient` library as a dependency to your project.
Register your application in [Dropbox App Console](https://www.dropbox.com/developers/apps).
Configure your app so that it can handle sign-in redirects. For an iOS app, you can do it by adding or modifying `CFBundleURLTypes` in `Info.plist`:
```xml
CFBundleURLTypes
CFBundleTypeRole
Editor
CFBundleURLName
CFBundleURLSchemes
db-abcd1234
```
Create the client:
```swift
import DropboxClient
let client = DropboxClient.Client.live(
config: .init(
appKey: "abcd1234",
redirectURI: "db-abcd1234://my-app"
)
)
```
Make sure the `redirectURI` contains the scheme defined earlier.
The package provides a basic implementation for storing vulnerable data securely in the keychain. Optionally, you can provide your own, custom implementation of a keychain, instead of using the default one.
```swift
import DropboxClient
let keychain = DropboxClient.Keychain(
loadCredentials: { () async -> DropboxClient.Credentials? in
// load from secure storage and return
},
saveCredentials: { (DropboxClient.Credentials) async -> Void in
// save in secure storage
},
deleteCredentials: { () async -> Void in
// delete from secure storage
}
)
let client = DropboxClient.Client.live(
config: .init(...),
keychain: keychain
)
```
### ▶️ Example
This repository contains an [example iOS application](Example/DropboxClientExampleApp) built with SwiftUI.
- Open `DropboxClient.xcworkspace` in Xcode.
- Example source code is contained in the `Example` Xcode project.
- Run the app using the `DropboxClientExampleApp` build scheme.
- The "Example" tab provides UI that uses `DropboxClient` library.
- The "Console" tab provides UI for browsing application logs and HTTP requests.
The example app uses [Dependencies](https://github.com/pointfreeco/swift-dependencies) to manage its own internal dependencies. For more information about the `Dependencies` library check out [official documentation](https://pointfreeco.github.io/swift-dependencies/main/documentation/dependencies).
## 🏛 Project structure
```
DropboxClient (Xcode Workspace)
├─ swift-dropbox-client (Swift Package)
| └─ DropboxClient (Library)
└─ Example (Xcode Project)
└─ DropboxClientExampleApp (iOS Application)
```
## 🛠 Develop
- Use Xcode (version ≥ 14.3.1).
- Clone the repository or create a fork & clone it.
- Open `DropboxClient.xcworkspace` in Xcode.
- Use the `DropboxClient` scheme for building the library and running unit tests.
- If you want to contribute, create a pull request containing your changes or bug fixes. Make sure to include tests for new/updated code.
## ☕️ Do you like the project?
## 📄 License
Copyright © 2023 Dariusz Rybicki Darrarski
License: [MIT](LICENSE)
