1

I am currently playing around with the Vimeo API and following the setup process and the guided readme found here:

(https://github.com/vimeo/VimeoNetworking)

All I am doing is pulling down publicly available videos from Vimeo except I have been receiving

Fatal error: Session manager did not return a task: file

everything else works and I am able to use my own token for authentication.

Here is the code I have right now that throws this error:

What am I doing wrong or missing?

let queryURL = URL(string: "/channels/staffpicks/videos")
        let videoRequest = Request<[VIMVideo]>(path: queryURL!.absoluteString)
        guard let sessionClient = _client else {
            return []
        }

        let _ = sessionClient.request(videoRequest, completion: {
            results in
            switch results {
            case .success(let response):
                let videos: [VIMVideo] = response.model

                for video in videos
                {
                    print("retrieved video: \(video)")
                }

                vVideo = videos

                break
            case .failure(let error):
                print(error.localizedDescription)

                break
            }
        })
pags_r1a
  • 11
  • 3

1 Answers1

2

Sorry I am late but this worked for me (using Swift 4.2):

let appConfiguration = AppConfiguration(
        clientIdentifier: Constants.VIMEO_CLIENT_IDENTIFIER,
        clientSecret: Constants.VIMEO_CLIENT_SECRET,
        scopes: [.Public], keychainService: "")
let vimeoSessionManager = VimeoSessionManager.defaultSessionManager(
        baseUrl: VimeoBaseURL,
        accessToken: Constants.VIMEO_ACCESS_TOKEN,
        apiVersion: "3.4")
let vimeoClient = VimeoClient(
        appConfiguration: appConfiguration,
        sessionManager: vimeoSessionManager)
let videoRequest = Request<[VIMVideo]>(path: "/videos?query=dragon+ball")
vimeoClient.request(videoRequest) {
        result in
        switch result {
        case .success(let response):
            let videos: [VIMVideo] = response.model
            print("\n\n retrieved videos: \(videos) \n\n")
        case .failure(let error):
            print("\n\n error retrieving videos: \(error) \n\n")
        }
    }

I'am almost sure you needed to add a session manager, but not 100% because haven't seen how you initialize the client and the other variables, so I am just adding this example.

  • Remember to get clientIndentifier, clientSecret and accessToken in [https://developer.vimeo.com/apps][1] (after you've created your app).

  • This is using a public accessToken, if you need authenticated access just add the .Private and .Interact scopes to the scopes array in appConfiguration, and to get an 'Authenticated' accessToken.

  • Also, please notice that I am using "/videos?query=dragon+ball" as an example.