You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

200ok's avatar
200ok
New member | Level 2
8 years ago

Custom TransportClient with programatic auth flow

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.

 

  • 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.)
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    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's avatar
      200ok
      New member | Level 2

      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's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff
        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.)

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,910 PostsLatest Activity: 3 days ago
333 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!