Want to know more about Dash? Check out how Amy uses Dropbox and Dash to make her day easier here!
Forum Discussion
vewert
4 years agoExplorer | Level 4
How to set clientIdentifier, using SwiftyDropbox
In the Java API, a clientIdentifier is set when creating a DbxRequestConfig object. I'm wondering, is there an equivalent in SwiftyDropbox? I was trying to search it myself, but it seem like the link (http://dropbox.github.io/SwiftyDropbox/api-docs/latest/ ) to the SwiftyDropbox api docs is broken.
Thanks
Yes, those are optional so you can set them to nil, except for "accessToken", but it looks like you can just set that to an empty string, assuming you're using the standard authorization functionality such as authorizeFromControllerV2 and authorizedClient which will take care of that for you.
13 Replies
- Greg-DB4 years ago
Dropbox Community Moderator
Thanks for letting us know about the broken docs page! I'll ask the team to fix that up.
Anyway, the equivalent of setting that custom identifier in the SwiftyDropbox SDK would be to set the "userAgent" parameter when making a "DropboxTransportClient", like seen here.
- vewert4 years agoExplorer | Level 4
Thanks Greg,
I looked at the sample. How do I create a DropboxTransportClient, if all I want to do is set the userAgent; can I set all the other parameters to nil, to get the default behaviour?
- Greg-DB4 years ago
Dropbox Community Moderator
Yes, those are optional so you can set them to nil, except for "accessToken", but it looks like you can just set that to an empty string, assuming you're using the standard authorization functionality such as authorizeFromControllerV2 and authorizedClient which will take care of that for you.
- vewert4 years agoExplorer | Level 4
Thanks, that seems to work.
Also, I noticed the link to the documentation now works, so thanks for that as well.
One side question, I was looking through the documentation, but other than the example code, I couldn't find the actual api documentation for DropboxTransportClient (listing its Declaration, Parameters, etc.), I'm not sure if I just can't find it, or if its not there.
- Greg-DB4 years ago
Dropbox Community Moderator
Yes, we got the docs back up. It looks like the DropboxTransportClient class in particular isn't being included in the documentation though. I'll see if we can get that done.
- vewert2 years agoExplorer | Level 4
Hi, sorry to re-open this discussion, but it seems like this isn't working anymore after upgrading SwiftyDropbox to 10 (10.0.1). It seems like when using a custom DropboxTransportClient, so I can set the user-agent, the access token doesn't get refreshed. After integrating with Dropbox, all my calls work fine, but if I don't use the app for awhile (4-5 hours), and then open the app again, I get a ".tag" = "expired_access_token" error.
If I change my code, and call DropboxClientsManager.setupWithAppKey() without passing a DropboxTransportClient, it seems to work.
I looked at the source code, and it seems there was a change to the code for the DropboxTranportClient
Which may cause this change of behaviour.
My code to create the DropboxTransportClient is as follows:
let transportClient: DropboxTransportClientImpl = DropboxTransportClientImpl( accessToken: "", userAgent: userAgent, selectUser: nil)
- Greg-DB2 years ago
Dropbox Community Moderator
In order for the SDK to perform the refresh for you, to avoid the "expired_access_token" error, it will need a refresh token.
Can you let me know if you're currently using the standard authorization functionality (authorizeFromControllerV2), or if you're supplying an access token/refresh token yourself?
The standard authorization functionality should handle this automatically for you.
Otherwise, can you show me how you're supplying the access token/refresh token? Please be sure to redact any access token or refresh token string itself though.
Thanks!
- vewert2 years agoExplorer | Level 4
Yes, I am using the standard authorization functionality (authorizeFromControllerV2) as in the sample code.
The difference between my code, and the sample code is in how a call `setupWithAppKey` inside the AppDelegate. In order to set the userAgent, I create an instance of transportClient:
let transportClient: DropboxTransportClientImpl = DropboxTransportClientImpl( accessToken: "", userAgent: userAgent, selectUser: nil)
and then call:
DropboxClientsManager.setupWithAppKey("<APP_KEY>", transportClient: transportClient)
if I don't use the transportClient, and simply call:
DropboxClientsManager.setupWithAppKey("<APP_KEY>")
then the refresh token seems to work, and I don't get the expired token error.
This used to all work before I upgraded to SwiftyDropbox 10 (10.0.1), but now it doesn't, so I suspect there may have been a change in the DropboxTransportClientImpl initializer code.
- Greg-DB2 years ago
Dropbox Community Moderator
Thanks! We'll look into it and follow up here once we have any news on this.
- vewert2 years agoExplorer | Level 4
Thanks, would it be helpful for me to log the issue in your GitHub repository (https://github.com/dropbox/SwiftyDropbox/issues)?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,017 PostsLatest Activity: 2 days ago
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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!