daneden / Twift

🐦 An async Swift library for the Twitter v2 API 🚧 WIP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem uploading image

atulbutte opened this issue · comments

Apologies if this has been discussed already, but I couldn't find any issues regarding image upload.

I'm trying the straight demo app, with no changes (except obviously for the Twitter API credentials). After successfully logging in, I'm trying to upload an image. Choosing a photo works. But tapping Upload image yields a problem.

I've traced it to the initializeUpload method in Twift+Media.swift line 120.

This code is throwing an exception

  fileprivate func initializeUpload(data: Data, mimeType: String) async throws -> MediaInitResponse {
    guard case .userAccessTokens(let clientCredentials, let userCredentials) = self.authenticationType else {
      throw TwiftError.WrongAuthenticationType(needs: .userAccessTokens)
    }

Is this an OAuth 1.0/2.0 issue? Tweeting straight text does work, from the same login and app, and the code to simply post a text tweet doesn't have the same check for userAccessTokens.

Thanks, -- Atul

Never mind, this is fully explained by media uploading not yet supported in the Twitter v2 API.