swift, SwiftyDropbox API: How can I get the user account name as a string

126 views Asked by At

I tried this, but can't get it to build and can't find example anywhere.

client = DropboxClientsManager.authorizedClient
let dropbox_account_name = client!.users.GetCurrentAccount().getAccountId()

BACKGROUND...
My Swift app uses DX API to connect to our Dropbox account and reads and writes files just fine.

Now we want to read what dropbox account name the user is using.

1

There are 1 answers

0
Greg On BEST ANSWER

Using getCurrentAccount works like the createFolder example from the SwiftyDropbox SDK. It would look like this:

client.users.getCurrentAccount().response { response, error in
    if let account = response {
        print(account.name.displayName)
        print(account.accountId)
    } else if let error = error {
        print(error)
    }
}