     return url
 }
 
-private func token(from url: URL, secret externalSecret: Data? = nil) throws -> Token? {
+private func token(from url: URL, secret externalSecret: Data? = nil) throws -> Token {
     guard url.scheme == kOTPAuthScheme else {
-        return nil
+        throw DeserializationError.invalidURLScheme
     }
 
     var queryDictionary = Dictionary<String, String>()

        throw DeserializationError.missingSecret
    }
    guard let generator = Generator(factor: factor, secret: secret, algorithm: algorithm, digits: digits) else {
        return nil
    }

    // Skip the leading "/"

    /// Attempts to initialize a token represented by the give URL.
    public init?(url: URL, secret: Data? = nil) {
        do {
            self = try token(from: url, secret: secret)
        } catch {
            return nil
        }
