Kitura Credentials framework OAuth2 token type authorization validation for Dropbox


Plugin for the Kitura-Credentials framework that authenticates using a Dropbox OAuth2 token


Plugin for Kitura-Credentials framework that authenticates using a Dropbox OAuth2 token that was acquired by a mobile app or other client of the Kitura based backend.

Table of Contents

Swift version

The latest version of CredentialsDropbox requires Swift 4.0. You can download this version of the Swift binaries by following this link. Compatibility with other Swift versions is not guaranteed.

Example of authentication with a Dropbox OAuth2 token

This example shows how to use CredentialsDropboxToken plugin to authenticate post requests, it shows both the server side and the client side of the request involved.

Server side

First create an instance of Credentials and an instance of CredentialsDropboxToken plugin:

import Credentials
import CredentialsDropbox

let credentials = Credentials()
let dropboxCredentials = CredentialsDropboxToken(options: options)


  • options is an optional dictionary ([String:Any]) of Dropbox authentication options whose keys are listed in CredentialsDropboxOptions.

Now register the plugin:


Connect credentials middleware to post requests:"/collection/:new", middleware: credentials)

If the authentication is successful, request.userProfile will contain user profile information received from Dropbox:"/collection/:new") {request, response, next in
  let profile = request.userProfile
  let userId =
  let userName = profile.displayName

Client side

The client needs to put a Dropbox access token in the request's access_token HTTP header field, and "DropboxToken" in the X-token-type field. And because Dropbox apparently doesn't have a direct means to validate an access token, you need to pass the dropbox uid with the header key X-account-id:

let urlRequest = NSMutableURLRequest(URL: NSURL(string: "http://\(serverUrl)/collection/\(name)"))
urlRequest.HTTPMethod = "POST"
urlRequest.HTTPBody = ...

urlRequest.addValue(dropboxAccessToken, forHTTPHeaderField: "access_token")
urlRequest.addValue("DropboxToken", forHTTPHeaderField: "X-token-type")
urlRequest.addValue(dropboxUid, forHTTPHeaderField: "X-account-id")
Alamofire.request(urlRequest).responseJSON {response in


This library is licensed under MIT. Full license text is available in LICENSE.


  • Swift Tools 5.0.0
View More Packages from this Author


Last updated: Mon Mar 13 2023 03:43:42 GMT-0500 (GMT-05:00)