Search code examples
swiftdropbox-apiswiftydropbox

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


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.


Solution

  • 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)
        }
    }