mattdonnelly / Swifter

[DEPRECATED] :bird: A Twitter framework for iOS & OS X written in Swift
MIT License
2.37k stars 387 forks source link

I want to use `Swifter.authorizeSSO(succees: _, failure: _)` but the authentication page does not appear on the app. just appear Home #346

Open dongminyoon opened 3 years ago

dongminyoon commented 3 years ago
let swifter = Swifter(consumerKey: "\(APPKEY)",
                              consumerSecret: "\(SCERETKEY)")

if let twitterUrl = URL(string: "twitterauth://"), 
    UIApplication.shared.canOpenURL(twitterUrl) {
    swifter.authorizeSSO(success: { accToken in
        print(accToken)
    }, failure: { error in
        print(error.localizedDescription)
    })

not appear authentication page just appear Twitter Home and appear log You should call login api before calling any im related api like thie

What can I do...?

0xhex commented 3 years ago

same issue guys,any solution? @dongminyoon

0xhex commented 3 years ago

@meteochu

ekurutepe commented 3 years ago

You can still do SSO although it's deprecated if you include the url scheme twitterkit-APP_ID in your Info.plist

This is obviously a hack but still works.

zunda-pixel commented 2 years ago

@ekurutepe what is APP_ID?

ekurutepe commented 2 years ago

@zunda-pixel Your twitter app ID

zunda-pixel commented 2 years ago

thanks. but it doesn't work for me.

スクリーンショット 2022-01-07 0 52 09
import SwiftUI
import Swifter

struct ContentView: View {
  let consumerKey = "fake"
  let consumerSecret = "fake"

  func getOauthToken() {
    let swifter = Swifter(consumerKey: consumerKey, consumerSecret: consumerSecret)

    let swifterFailureHandler: Swifter.FailureHandler = { error in
      print(error)
    }

    let swifterSuccessHandler: Swifter.SSOTokenSuccessHandler = { json in
      print(json)
    }

    swifter.authorizeSSO(success: swifterSuccessHandler, failure: swifterFailureHandler)
  }

  var body: some View {
    Button("Login with Twitter") {
      getOauthToken()
    }
  }
}