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: 

Problem with using Generated access token to test using SwiftyDropbox

Problem with using Generated access token to test using SwiftyDropbox

UWRL
Explorer | Level 4
Go to solution

I have followed the instructions on https://github.com/dropbox/SwiftyDropbox in an attempt to test the V2 API with my Swift desktop macOS App.  The only difference is that I am using the Swift_2_3 branch.

 

When inputting my "Generated access token", from my App page on my account, and compiling I get an error on this line:

 

let client = DropboxClient(accessToken: "GENERATED_ACCESS_CODE_HERE")

 

The error is "Connot convert value of type 'String' to expected argument type 'DropboxAccessToken'"

 

I've attempted to cast the string into the correct type but nothing is working.

2 Accepted Solutions

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

The Swift 3 branch has the DropboxClient constructor just taking the access token as a string now, but the Swift 2.3 branch still requires a DropboxAccessToken object there. You can construct it like this:

 

DropboxClient.init(accessToken: DropboxAccessToken(accessToken:"ACCESS_TOKEN_HERE", uid:"USER_ID_HERE"))

View solution in original post

Steve M.
Dropbox Staff
Go to solution

Just use client instead of Dropbox.authorizedClient:

 

client.sharing.createSharedLinkWithSettings(...)

View solution in original post

3 Replies 3

Greg-DB
Dropbox Staff
Go to solution

The Swift 3 branch has the DropboxClient constructor just taking the access token as a string now, but the Swift 2.3 branch still requires a DropboxAccessToken object there. You can construct it like this:

 

DropboxClient.init(accessToken: DropboxAccessToken(accessToken:"ACCESS_TOKEN_HERE", uid:"USER_ID_HERE"))

UWRL
Explorer | Level 4
Go to solution

Thanks for that help. That pushed me along a little further. I'm trying to retrieve a public shared link for a folder. This is what I have so far:

 

var client = DropboxClient.init(accessToken: DropboxAccessToken(accessToken:"ACESS_TOKEN", uid:"UID_NUMBER"))
                
Dropbox.authorizedClient?.sharing.createSharedLinkWithSettings(path: dropboxItemName).response({ response, error in
    if let link = response {
      print("link.url: " + link.url)
    } else {
      print("error: ")
      print(error!)
    }
})

Unfortunately I'm not getting anything from either "print" statement in the "if" statement in the Dropbox.authorizedClient statement. Any suggestions? Am I missing something here?

Steve M.
Dropbox Staff
Go to solution

Just use client instead of Dropbox.authorizedClient:

 

client.sharing.createSharedLinkWithSettings(...)
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Steve M. Dropbox Staff
  • User avatar
    UWRL Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?