Search code examples
swiftalamofirevimeo-api

Retrieve list of videos from folder in Vimeo Swift 5


I want to query a page of videos from a folder I have hosted on Vimeo. However when doing so, I receive:

Error Domain=com.alamofire.error.serialization.response Code=1011 "Request failed: not found (404)" UserInfo={NSLocalizedDescription=Request failed: not found (404), NSErrorFailingURLKey=https://api.vimeo.com/users/{user-id}/projects/{project-id}/videos, com.alamofire.serialization.response.error.data={length = 51, bytes = 0x7b226572 726f7222 3a225468 65207265 ... 666f756e 642e227d }, ...

I have attempted using different endpoints of the forms: /users/{user-id}/folders/{folder-id}/videos, /users/{user-id}/projects/{project-id}, and /users/{user-id}/folders/{folder-id}, all giving back the same error. I'm currently creating the client and requesting the videos this way:

appConfiguration = AppConfiguration(clientIdentifier: "{id}",
    clientSecret: "{secret}", scopes: [.Public, .Private], keychainService: "")
sessionManager = VimeoSesssionManager.defaultSessionManager(baseUrl: VimeoBaseURL,
    accessToken: "{access_token}", apiVersion: "3.4")
client = VimeoClient(appConfiguration: appConfiguration, sessionManager: sessionManager)

...

var request: Request? = Request<[VIMVideo]>(path: path)
_ = client.request(request) { result in
    switch result {
    case .success(let response):
        ...
    case .failure(let error):
        print("Error retrieving videos: \(error)")
    }
}

However, I have also tried authenticating before hand using the AuthenticationController as specified in the VimeoNetworking GitHub. When testing with the folder id's and the user id on Vimeo's API Reference webpage, everything works fine and I'm able to receive the page of videos just fine.

So I just want to know what I need to do differently to retrieve the page of videos as I was able to do in the Vimeo API Reference website.


Solution

  • The reason the 404 error was being returned was because the Access Token I had created for the application only had the "public" modifier, but when I created a token with the public, private, and video_files, modifiers it worked as expected!