         
         /// An error that was returned from the API.
         case APIError(GitHubError)
+    }
+    
+    /// Credentials for the GitHub API.
+    internal enum Credentials {
+        case Token(String)
+        case Basic(username: String, password: String)
+        
+        var authorizationHeader: String {
+            switch self {
+            case let .Token(token):
+                return "token \(token)"
+            case let .Basic(username, password):
+                let data = "\(username):\(password)".dataUsingEncoding(NSUTF8StringEncoding)!
+                let encodedString = data.base64EncodedStringWithOptions([])
+                return "Basic \(encodedString)"
+            }
+        }
     }
     
     /// A GitHub API endpoint.

}

extension NSURLRequest {
    internal static func create(server: Server, _ endpoint: Client.Endpoint) -> NSURLRequest {
        let URL = NSURL(string: server.endpoint)!.URLByAppendingPathComponent(endpoint.path)
        return NSURLRequest(URL: URL)
    }
}


    internal func fetchOne<Object: Decodable where Object.DecodedType == Object>(endpoint: Endpoint) -> SignalProducer<Object, Error> {
        return NSURLSession
            .sharedSession()
            .rac_dataWithRequest(NSURLRequest.create(server, endpoint, credentials))
            .mapError(Error.NetworkError)
            .flatMap(.Concat) { data, response -> SignalProducer<Object, Error> in
                let response = response as! NSHTTPURLResponse
