     public func login(from controller: UINavigationController, withScopes scopes: [InstagramScope] = [.basic], success: EmptySuccessHandler?, failure: FailureHandler?) {
         if let authURL = buildAuthURL(scopes: scopes) {
             let vc = InstagramLoginViewController(authURL: authURL, success: { accessToken in
-                if !self.keychain.set(accessToken, forKey: Keychain.key) {
+                if !self.storeAccessToken(accessToken) {
                     failure?(InstagramError(kind: .keychainError(code: self.keychain.lastResultCode), message: "Error storing access token into keychain."))
                 } else {
                     controller.popViewController(animated: true)


        var items = [URLQueryItem]()

        let accessToken = keychain.get(Keychain.key)
        items.append(URLQueryItem(name: "access_token", value: accessToken ?? ""))

        parameters?.forEach({ parameter in
            items.append(URLQueryItem(name: parameter.key, value: "\(parameter.value)"))


    @discardableResult
    public func logout() -> Bool {
        return deleteAccessToken()
    }

    // MARK: - Access Token

    func storeAccessToken(_ accessToken: String) -> Bool {
        return keychain.set(accessToken, forKey: Keychain.accessTokenKey)
    }

    func retrieveAccessToken() -> String? {
        return keychain.get(Keychain.accessTokenKey)
    }

    func deleteAccessToken() -> Bool {
        return keychain.delete(Keychain.accessTokenKey)
    }

    // MARK: -
