Skip to content

Commit ee41bf0

Browse files
committed
Update README.md
1 parent e5d0eed commit ee41bf0

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

README.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,69 @@
55

66
Basic Dropbox HTTP API client that does not depend on Dropbox's SDK. No external dependencies.
77

8+
- Authorize access
9+
- ...
10+
811
## 📖 Usage
912

1013
Use [Swift Package Manager](https://swift.org/package-manager/) to add the `DropboxClient` library as a dependency to your project.
1114

12-
*TBD*
15+
Register your application in [Dropbox App Console](https://www.dropbox.com/developers/apps).
16+
17+
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`:
18+
19+
```xml
20+
<key>CFBundleURLTypes</key>
21+
<array>
22+
<dict>
23+
<key>CFBundleTypeRole</key>
24+
<string>Editor</string>
25+
<key>CFBundleURLName</key>
26+
<string></string>
27+
<key>CFBundleURLSchemes</key>
28+
<array>
29+
<string>db-abcd1234</string>
30+
</array>
31+
</dict>
32+
</array>
33+
```
34+
35+
Create the client:
36+
37+
```swift
38+
import DropboxClient
39+
40+
let client = DropboxClient.Client.live(
41+
config: .init(
42+
appKey: "abcd1234",
43+
redirectURI: "db-abcd1234://my-app"
44+
)
45+
)
46+
```
47+
48+
Make sure the `redirectURI` contains the scheme defined earlier.
49+
50+
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.
51+
52+
```swift
53+
import DropboxClient
54+
55+
let keychain = DropboxClient.Keychain(
56+
loadCredentials: { () async -> DropboxClient.Credentials? in
57+
// load from secure storage and return
58+
},
59+
saveCredentials: { (DropboxClient.Credentials) async -> Void in
60+
// save in secure storage
61+
},
62+
deleteCredentials: { () async -> Void in
63+
// delete from secure storage
64+
}
65+
)
66+
let client = DropboxClient.Client.live(
67+
config: .init(...),
68+
keychain: keychain
69+
)
70+
```
1371

1472
### ▶️ Example
1573

0 commit comments

Comments
 (0)