You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,11 +22,53 @@ dependencies: [
22
22
23
23
Start by initializing `Transloadit`.
24
24
25
+
### Simple initialization; pass key and secret to the SDK
26
+
25
27
```swift
26
28
let credentials = Transloadit.Credentials(key: "SomeKey", secret: "SomeSecret")
27
29
let transloadit =Transloadit(credentials: credentials, session: URLSession.shared)
28
30
```
29
31
32
+
Certain transloadit endpoints (can) require signatures to be included in their requests. The SDK can automatically generate signatures on your behalf but this requires you to pass both your Transloadit key _and_ secret to the SDK.
33
+
34
+
The SDK does not persist your secret locally beyond the SDK's lifetime.
35
+
36
+
This means that you're free to obtain your SDK secret in a secure manner from an external host or that you can include it in your app binary. It's up to you.
37
+
38
+
It's also possible to initialize the SDK with a `nil` secret and manage signing yourself.
39
+
40
+
### Advanced initialization; omit secret for manual request signing
41
+
42
+
If, for security reasons, you choose to not expose your API secret to the app in any way, shape, or form, you can manage signature generation yourself. This allows you to generate signatures on your server and provide them to Transloadit as needed.
43
+
44
+
To do this, use the `Transloadit` initializer that takes an api key and a `signatureGenerator`
45
+
46
+
```swift
47
+
let transloadit =Transloadit(
48
+
apiKey: "YOUR-API-KEY",
49
+
sessionConfiguration: .default,
50
+
signatureGenerator: { stringToSign, onSignatureGenerated in
The generator itself is passed a string that needs to be signed (a JSON representation of the request parameters that you're generating a signature for) and a closure that you _must_ call to inform the SDK when you're done generating the signature (whether it's successful or failed).
65
+
66
+
**Important** if you don't call the completion handler, your requests will never be sent. The SDK does not implement a fallback or timeout.
67
+
68
+
The SDK will invoke the signature generator for every request that requires a signature. It will pass a parameter string for each request to your closure which you can then send to your service (local or external) for signature generation.
69
+
70
+
To learn more about signature generation see this page: https://transloadit.com/docs/api/authentication/
71
+
30
72
### Create an Assembly
31
73
32
74
To create an `Assembly` you invoke `createAssembly(steps:andUpload:completion)` on `Transloadit`.
0 commit comments