[GH-ISSUE #543] Flickr oauth1 succeeds, but then photo upload to returns: No Photo specified #358

Closed
opened 2026-03-03 16:48:02 +03:00 by kerem · 2 comments
Owner

Originally created by @CAoTx on GitHub (Aug 30, 2019).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/543

@phimage @dongri

Description:

Hello, using the OAuth1 procedure to get authenticated with flickr. Works until the actual photo upload proceeds.
Flickr response with the error Message: No Photo Specified. I'm providing a jpeg image.

Here's my code.

    oAuthSwift = OAuth1Swift(consumerKey: flickr.apiKey,
                             consumerSecret: flickr.apiSecret,
                             requestTokenUrl: "https://www.flickr.com/services/oauth/request_token",
                             authorizeUrl: "https://www.flickr.com/services/oauth/authorize",
                             accessTokenUrl: "https://www.flickr.com/services/oauth/access_token")
    
    if oAuthSwift != nil {
        oAuthSwift?.authorizeURLHandler = SafariURLHandler(viewController: self, oauthSwift: oAuthSwift!)
        
        guard let rwURL = URL(string: "iflickr://oauth-callback/iflickr") else {
            return
        }
        //            let handle = oAuthSwift!.authorize(withCallbackURL: rwURL, headers: headers) { [unowned self] result in
        let handle = oAuthSwift!.authorize( withCallbackURL: rwURL) { [unowned self] result in
            switch result {
            case .success(let (credential, response, parameters)):
                print(credential.oauthToken)
                print(credential.oauthTokenSecret)
                
                guard let img = self.image?.jpegData(compressionQuality: 0.0) else {
                    print ("cant convert image")
                    return
                }
                var params = parameters
      //        params["photo"] = img
                self.oAuthSwift!.client.postImage(flickr.uploadEndpoint, parameters: params, image: img) { upResult in
                    switch upResult {
                    case .failure(let error):
                        print (error)
                    case .success(let response):
                        let respData = response.data
                        if let string = response.string {
                            print ("\nRESULT:\n      - \(string)\n")
                        }
                    }
                }
            // Do your request
            case .failure(let error):
                print(error.localizedDescription)
            }
        }
    }

OAuth Provider? (Twitter, Github, ..):

Flickr

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

  • iOS :
  • OSX :
  • TVOS :
  • WatchOS :

Installation method:

  • Carthage
  • CocoaPods
  • Swift Package Manager
  • [ x] Manually

Library version:

  • head
  • v2.0.0
  • v1.4.1
  • v1.2.1
  • v1.2 (Swift 4.0)
  • v1.0.0
  • v0.6
  • other: (Please fill in the version you are using.)
  • pulled yesterday

Xcode version:

  • 11.x (Swift 5.1)

  • 10.x (Swift 5.0)

  • 10.x (Swift 4.1)

  • 9.3 (Swift 4.1)

  • 9.0 (Swift 4.0)

  • other: (Please fill in the version you are using.)

  • objective c

Originally created by @CAoTx on GitHub (Aug 30, 2019). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/543 @phimage @dongri ### Description: Hello, using the OAuth1 procedure to get authenticated with flickr. Works until the actual photo upload proceeds. Flickr response with the error Message: No Photo Specified. I'm providing a jpeg image. Here's my code. ------------------------ oAuthSwift = OAuth1Swift(consumerKey: flickr.apiKey, consumerSecret: flickr.apiSecret, requestTokenUrl: "https://www.flickr.com/services/oauth/request_token", authorizeUrl: "https://www.flickr.com/services/oauth/authorize", accessTokenUrl: "https://www.flickr.com/services/oauth/access_token") if oAuthSwift != nil { oAuthSwift?.authorizeURLHandler = SafariURLHandler(viewController: self, oauthSwift: oAuthSwift!) guard let rwURL = URL(string: "iflickr://oauth-callback/iflickr") else { return } // let handle = oAuthSwift!.authorize(withCallbackURL: rwURL, headers: headers) { [unowned self] result in let handle = oAuthSwift!.authorize( withCallbackURL: rwURL) { [unowned self] result in switch result { case .success(let (credential, response, parameters)): print(credential.oauthToken) print(credential.oauthTokenSecret) guard let img = self.image?.jpegData(compressionQuality: 0.0) else { print ("cant convert image") return } var params = parameters // params["photo"] = img self.oAuthSwift!.client.postImage(flickr.uploadEndpoint, parameters: params, image: img) { upResult in switch upResult { case .failure(let error): print (error) case .success(let response): let respData = response.data if let string = response.string { print ("\nRESULT:\n - \(string)\n") } } } // Do your request case .failure(let error): print(error.localizedDescription) } } } ---------------------- ### OAuth Provider? (Twitter, Github, ..): Flickr ### OAuth Version: - [x] Version 1 - [ ] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [ ] CocoaPods - [ ] Swift Package Manager - [ x] Manually ### Library version: - [ ] head - [ ] v2.0.0 - [ ] v1.4.1 - [ ] v1.2.1 - [ ] v1.2 (Swift 4.0) - [ ] v1.0.0 - [ ] v0.6 - [ ] other: (Please fill in the version you are using.) - [x] pulled yesterday ### Xcode version: - [ ] 11.x (Swift 5.1) - [ ] 10.x (Swift 5.0) - [x] 10.x (Swift 4.1) - [ ] 9.3 (Swift 4.1) - [ ] 9.0 (Swift 4.0) - [ ] other: (Please fill in the version you are using.) - [ ] objective c
kerem closed this issue 2026-03-03 16:48:03 +03:00
Author
Owner

@phimage commented on GitHub (Aug 31, 2019):

please provide a link to the doc where the upload of photo is

<!-- gh-comment-id:526820552 --> @phimage commented on GitHub (Aug 31, 2019): please provide a link to the doc where the upload of photo is
Author
Owner

@CAoTx commented on GitHub (Sep 2, 2019):

Hey,

i found the problem.

The flickr upload API requests the parameter for the actual photo data named "photo" instead of "media", which was provided.
github.com/OAuthSwift/OAuthSwift@b8941a23d1/Sources/OAuthSwiftClient.swift (L125)

I just changed that and everything works like a charm.
Thank you!

<!-- gh-comment-id:527183587 --> @CAoTx commented on GitHub (Sep 2, 2019): Hey, i found the problem. The flickr upload API requests the parameter for the actual photo data named "photo" instead of "media", which was provided. https://github.com/OAuthSwift/OAuthSwift/blob/b8941a23d1584ba17426c312bb957de355341f4a/Sources/OAuthSwiftClient.swift#L125 I just changed that and everything works like a charm. Thank you!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#358
No description provided.