cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Custom TransportClient with programatic auth flow

Custom TransportClient with programatic auth flow

200ok
New member | Level 2
Go to solution

So, you must start with your AppDelegate calling this:

 

 

setupWithAppKey()

 

in order to later initiate the auth flow and retrieve an AccessToken, etc.

 

The SDK will remember your auth info next time and provide an `authorizedClient` – all good.

 

Now, I want to use a custom `DropboxTransportClient` and the only point at which you can inject a certain / custom `DropboxTransportClient` is in:

 

 

DropboxClientsManager.setupWithAppKey(DropboxUtil.key, transportClient: transportClient)

 

However, once you've called setupWithAppKey once, you cannot call it again:

 

precondition failed: Only call `DropboxClientsManager.setupWithAppKey` or `DropboxClientsManager.setupWithTeamAppKey` once: file Swift/Pods/SwiftyDropbox/Source/SwiftyDropbox/PlatformNeutral/DropboxClientsManager.swift, line 22

How can we use the nice programatic auth flow and also inject our own `DropboxTransportClient` ?

 

I wish to limit the number of simeltaneous uploads, and I think that is possible if I can control the Transport Client.

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution
I see, thanks for elaborating. In that case, you can just pass in "" as the access token in the DropboxTransportClient, and then use that with setupWithAppKey. It should still then use the automatic auth flow and client. Give that a try and let me know if it doesn't work for you. (We're planning on making this more obvious/usable in a future version.)

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

The auth flow and client retrieval should work regardless of which version of setupWithAppKey you used, so you should be able to just use the one that takes a transport client in the first place. Does that work for you?

200ok
New member | Level 2
Go to solution

Hey Greg, thanks. Let me clarify the problem. I wish to inject a custom DropboxTransportClient. Creating a DropboxTransportClient requires an AccessToken (first constructor argument). I cannot have the user fetch his/her own access token until I've already called setupWithAppKey once, after which I cannot call setupWithAppKey again. The only injection point for a `TransportClient` is calling the overloaded version of `setupWithAppKey`, which can only be called once. â€“ I'm sure I'm misunderstanding something.

Greg-DB
Dropbox Staff
Go to solution
I see, thanks for elaborating. In that case, you can just pass in "" as the access token in the DropboxTransportClient, and then use that with setupWithAppKey. It should still then use the automatic auth flow and client. Give that a try and let me know if it doesn't work for you. (We're planning on making this more obvious/usable in a future version.)

200ok
New member | Level 2
Go to solution

That seems to work just fine indeed, thank you. Wasn't clear at first since there is no empty initializer.

 

I do have related questions but I will put them off for a time when I can give you the great examples you deserve!!! Thanks for the excellent support. 🙂

 

Need more support?