         authorizationParameters["oauth_timestamp"] = String(Int(Date().timeIntervalSince1970))
         authorizationParameters["oauth_nonce"] = UUID().uuidString
 
-        if let token = accessToken {
-            authorizationParameters["oauth_token"] = token
-        }
-
-        for (key, value) in parameters where key.hasPrefix("oauth_") {
-            authorizationParameters.updateValue(value, forKey: key)
+        if let accessToken = accessToken {
+            authorizationParameters["oauth_token"] = accessToken
+        }
+
+        if let parameters = parameters {
+            for (key, value) in parameters where key.hasPrefix("oauth_") {
+                authorizationParameters.updateValue(value, forKey: key)
+            }
         }
 
         var finalParameters = authorizationParameters
         if isMediaUpload {
-            for (k, v) in authorizationParameters {
-                finalParameters[k] = v
-            }
-            for (k, v) in parameters {
-                finalParameters[k] = v
-            }
-        }
-
-        authorizationParameters["oauth_signature"] = self.oauthSignature(for: method, urlString: urlString, parameters: finalParameters, appKey: appKey, accessToken: accessToken)
+            if let parameters = parameters {
+                for (k, v) in parameters {
+                    finalParameters[k] = v
+                }
+            }
+        }
+
+        authorizationParameters["oauth_signature"] = self.oauthSignature(for: method, urlString: urlString, parameters: finalParameters, appKey: appKey, accessTokenSecret: accessTokenSecret)
         let authorizationParameterComponents = authorizationParameters.urlEncodedQueryString(using: .utf8).components(separatedBy: "&").sorted()
         var headerComponents = [String]()
-
         for component in authorizationParameterComponents {
             let subcomponent = component.components(separatedBy: "=")
             if subcomponent.count == 2 {

                }
            }

            if let httpResponse = response as? HTTPURLResponse {
                if data != nil,
                   httpResponse.statusCode == 200,
                   httpResponse.url!.absoluteString.contains("api.twitter.com") {

                    let responseText = String(data: data!, encoding: .utf8)
                    // oauth_token=sample&oauth_token_secret=sample&oauth_callback_confirmed=true
                    json = responseText?.queryStringParameters
                    return
                }


    }


    func oauthSignature(for method: Method, urlString: String, parameters: Dictionary<String, Any>, appKey: String, accessTokenSecret tokenSecret: String?) -> String {
        let tokenSecret = tokenSecret?.urlEncodedString() ?? ""
        let encodedConsumerSecret = appKey.urlEncodedString()
        let signingKey = "\(encodedConsumerSecret)&\(tokenSecret)"
        let parameterComponents = parameters.urlEncodedQueryString(using: .utf8).components(separatedBy: "&").sorted()
