     return encoded!.base64EncodedString()
   }
 
-  static func synchronousRequest(_ urlString: String, headers: [String: String]? = nil, method: HTTPMethod? = nil, body: String? = nil) -> JSONResponse {
-    return Utils.synchronousRequest(urlString, headers: headers, method: method, body: body?.data(using: .utf8))
-  }
-
-  static func synchronousRequest(_ urlString: String, headers maybeHeaders: [String: String]? = nil, method maybeMethod: HTTPMethod? = nil, body: Data? = nil) -> JSONResponse {
+  static func synchronousRequest(_ url: URL, headers: [String: String]? = nil, method: HTTPMethod? = nil, body: String? = nil) -> JSONResponse {
+    return Utils.synchronousRequest(url, headers: headers, method: method, body: body?.data(using: .utf8))
+  }
+
+  static func synchronousRequest(_ url: URL, headers maybeHeaders: [String: String]? = nil, method maybeMethod: HTTPMethod? = nil, body: Data? = nil) -> JSONResponse {
     let method = maybeMethod ?? .GET
     let headers = maybeHeaders ?? [:]
 
-    let url = URL(string: urlString)!
     var data: Data?
     var response: HTTPURLResponse!
     var error: Error?

    return apiRequest(route, method: method, body: thisVarHelpsAvoidAmbiguity)
  }

  private func refreshToken() -> String {
    let auth = Utils.b64("\(credentials.clientId):\(credentials.clientSecret)")
    let (json, response, _) = Utils.synchronousRequest(
      "https://accounts.spotify.com/api/token",
      headers: ["Authorization": "Basic \(auth)"],
      method: .POST,
      body: "grant_type=refresh_token&refresh_token=\(credentials.refreshToken)"

    }
  }

  struct Playlist {
    let id: String
    let name: String

    static func from(_ dict: [String: Any]) -> Playlist {
      let id = dict["id"] as! String
      let name = dict["name"] as! String

      return Playlist(id: id, name: name)
    }
  }

  var db: DB

  var credentials: Credentials {
