daneden / Twift

🐦 An async Swift library for the Twitter v2 API 🚧 WIP
MIT License
111 stars 25 forks source link

Problem uploading image #62

Closed atulbutte closed 1 year ago

atulbutte commented 1 year ago

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

atulbutte commented 1 year ago

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