cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

How to set clientIdentifier, using SwiftyDropbox

How to set clientIdentifier, using SwiftyDropbox

vewert
Explorer | Level 4
Go to solution

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

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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.

View solution in original post

13 Replies 13

Greg-DB
Dropbox Staff
Go to solution

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.

vewert
Explorer | Level 4
Go to solution

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-DB
Dropbox Staff
Go to solution

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.

vewert
Explorer | Level 4
Go to solution

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-DB
Dropbox Staff
Go to solution

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.

vewert
Explorer | Level 4
Go to solution

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

https://github.com/dropbox/SwiftyDropbox/commit/56174418e996d4f409467cb1a21b486279c9abd5#diff-a9fb3e... 

 

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-DB
Dropbox Staff
Go to solution

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!

vewert
Explorer | Level 4
Go to solution

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-DB
Dropbox Staff
Go to solution

Thanks! We'll look into it and follow up here once we have any news on this.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    vewert Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?