         getToken(with: "grant_type=authorization_code&code=\(code)&redirect_uri=\(self.redirect_uri)")
     }
     
-    func getToken(with params:String){
+    func getToken(with params:String) {
         
         let url = URL(string: "https://www.reddit.com/api/v1/access_token")!
         let session = URLSession.shared

                    UserDefaults.standard.setValue(self.token.value(forKey: "refresh_token"), forKey: "refresh_token")
                  
                    
                }else{ // and this is for token refresh, so just update the access_token
                    
                    let JSONDictionary = NSMutableDictionary.init(dictionary: JSONReturn)
                    self.token.setValue(JSONDictionary.value(forKey: "access_token"), forKey: "access_token")

            restoreFromUserDefault(key: "valid_through")
        }
        
        //checks for token existance and expiration date
        
        if self.token.allKeys.count == 0 { // // if user have to authorize with user/password

            NotificationCenter.default.post(name:.oAuthNeedsUserLogin, object: nil, userInfo: nil)
            
        } else if let validThrough = self.token["valid_through"] as? Date, validThrough.isPassed() { // has a token, just have to refresh it

            refreshToken()

        } else if let validThrough = self.token["valid_through"] as? Date, !validThrough.isPassed() { // has a valid token

            NotificationCenter.default.post(name:.tokenDidAuthorize, object: self.token, userInfo: nil)

        }
    }
}
