                     messageAs: [
                         "access_token": sess!.accessToken,
                         "encrypted_refresh_token": sess!.encryptedRefreshToken,
-                        "expires_in": sess!.expirationDate.timeIntervalSinceNow * 1000
+                        "expires_in": (sess!.expirationDate.timeIntervalSinceNow * 1000).rounded(.down)
                     ]
                 )
                 

            
            svc.presentingViewController!.dismiss(animated: true, completion: nil)
            NotificationCenter.default.removeObserver(observer!)
            
            auth.handleAuthCallback(withTriggeredAuthURL: url) { (err, sess) in
                guard err == nil else {

import Foundation
import SafariServices

@objc(SpotifyOAuthPlugin) class SpotifyOAuthPlugin: CDVPlugin, SFSafariViewControllerDelegate {
    private var currentCommand: CDVInvokedUrlCommand?
    private var currentNsObserver: AnyObject?
    
    func authorize(_ command: CDVInvokedUrlCommand) {
        let auth = SPTAuth.defaultInstance()!
        
