                     observer.sendCompleted()
                 }
             }
-            self.fetch(route, callback: callback)
+            disposable.observeEnded {
+                req.cancel()
+            }
         }
     }
 
     func fetchItems<T: JSONInitializable>(_ route: Router) -> SignalProducer<[T], NSError> {
         return SignalProducer { observer, disposable in
-            let callback: OAuth2ClientDelegate.RequestCallback = {(response: DataResponse<Any
-                >) -> Void in
+            let req = self.manager.request(route).validate(statusCode: 200..<300).responseJSON(options: .allowFragments) {(response: DataResponse<Any>) -> Void in
                 if let e = response.result.error as NSError? {
                     if let r = response.response {
                         observer.send(error: NSError(domain: e.domain, code: e.code, userInfo: [APIClient.errorResponseKey:r]))

    public static var authUrl        = "https://soundcloud.com/connect"
    public static var tokenUrl       = "\(baseUrl)/oauth2/token"
    public static var scope          = Set([] as [String])
    public static var redirectUrl    = "http://localhost/"
    public static var accountType    = "SoundCloud"
    public static var keyChainGroup  = "SoundCloud"

    static let errorResponseKey = "com.alamofire.serialization.response.error.response"

    fileprivate static let userDefaults = UserDefaults.standard
    static func newManager() -> SessionManager {
        let m = Alamofire.SessionManager()
        if let token = APIClient.accessToken {
            m.session.configuration.httpAdditionalHeaders = ["Authorization": "Bearer \(token)"]
        }
        return m
    }

    static var oauth2clientDelegate: OAuth2ClientDelegate!
    static func createOauth2client(_ delegate: OAuth2ClientDelegate) -> NXOAuth2Client? {
        if let accessToken = account?.accessToken {
            return NXOAuth2Client(clientID: clientId,
                              clientSecret: clientSecret,
                              authorizeURL: URL(string: authUrl)!,
                                  tokenURL: URL(string: tokenUrl)!,
                               accessToken: accessToken,
                             keyChainGroup: keyChainGroup,
                                persistent: true,
                                  delegate: delegate)
        } else {
            return nil
        }
    }

    fileprivate static var _account: NXOAuth2Account?
    public static var account: NXOAuth2Account? {
        if let a = _account {
            return a
        }
        let store = NXOAuth2AccountStore.sharedStore() as! NXOAuth2AccountStore
        for account in store.accounts as! [NXOAuth2Account] {
            if account.accountType == APIClient.keyChainGroup {
                _account = account
                return account
            }
        }
        return nil
    }

    fileprivate static var _me: User?

import NXOAuth2Client
import ReactiveSwift
import Alamofire
import OAuthSwift
import Prephirences

open class SoundCloudOAuthRequestRetrier: OAuthRequestRetrier {
    public override func refreshed(_ succeeded: Bool) {
        if succeeded {
            APIClient.credential = oauth.client.credential
            APIClient.accessToken = oauth.client.credential.oauthToken
        } else {
            APIClient.credential = nil
            APIClient.accessToken = nil
        }
    }
}

