             }
         }
 
-        var type = TokenType.Timer
-        if let typeFromURL = TokenType.fromRaw(url.host) {
-            type = typeFromURL
-        } else {
-            return nil
+        var type: TokenType?
+        if let host = url.host {
+            type = TokenType.fromRaw(host)
         }
+        if !type { return nil } // A token type is required
 
-        var secretForToken = NSData()
-        if let secret = secret {
-            secretForToken = secret
-        } else {
+        var secret = externalSecret
+        if !secret {
             if let secretString = queryDictionary[kQuerySecretKey] {
-                secretForToken = NSData(base32String:secretString)
+                secret = NSData(base32String:secretString)
             }
         }
+        if !secret { return nil } // A secret is required
 
         var name = ""
         if let path = url.path {

let kQueryIssuerKey = "issuer"

extension Token {
    class func tokenWithURL(url: NSURL, secret: NSData? = nil) -> Token? {
        if (url.scheme != kOTPAuthScheme) { return nil }

        var queryDictionary = Dictionary<String, String>()

            if let algorithmFromURL = Algorithm.fromRaw(algorithmString) {
                algorithm = algorithmFromURL
            } else {
                return nil // Parsed an unknown algorithm string
            }
        }

