[GH-ISSUE #726] Twitter login not rediret #472

Open
opened 2026-03-03 16:48:55 +03:00 by kerem · 0 comments
Owner

Originally created by @joealzhou on GitHub (Dec 3, 2024).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/726

Description:

I didn't jump to the authorization page after logging in with Twitter for the first time, and I couldn't authorize it until I logged out of Safari and clicked the Twitter login button in the app again to open Safari. Is this normal?

self.oauthswift = OAuth1Swift(
consumerKey: TwitterKey,
consumerSecret: TwitterSecret,
requestTokenUrl: "https://api.x.com/oauth/request_token",
authorizeUrl: "https://api.x.com/oauth/authorize",
accessTokenUrl: "https://api.x.com/oauth/access_token"
)
let safariHandler = SafariURLHandler(viewController: self, oauthSwift: oauthswift!)
safariHandler.factory = { url in
return SFSafariViewController(url: url)
}
safariHandler.presentCompletion = { [weak self] in
self?.hud.hide(animated: false)
}
safariHandler.dismissCompletion = {
debugPrint("dismiss")
}
hud.show(animated: false)
oauthswift?.authorizeURLHandler = safariHandler
oauthswift?.authorize(withCallbackURL: TwitterAuthScheme, completionHandler: {[weak self] result in
switch result {
case .success(let (_, _, parameters)):
if let userid = parameters["user_id"] as? String, let userName = parameters["screen_name"] as? String {
debugPrint("login twitter userid: (userid) name: (userName)")
}
break
case .failure(let error):
self?.view.makeToast(error.localizedDescription)
}
})

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

OAuth Version:

  • Version 1
  • [*] Version 2

OS (Please fill the version) :

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

Installation method:

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

Library version:

  • head
  • v2.1.0
  • [ *] v2.2.0
  • v1.4.1
  • other: (Please fill in the version you are using.)

Xcode version:

  • 11.4 (Swift 5.2)

  • 11.x (Swift 5.1)

  • [ *] 15.4 (Swift 5.5)

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

  • objective c

Originally created by @joealzhou on GitHub (Dec 3, 2024). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/726 ### Description: I didn't jump to the authorization page after logging in with Twitter for the first time, and I couldn't authorize it until I logged out of Safari and clicked the Twitter login button in the app again to open Safari. Is this normal? self.oauthswift = OAuth1Swift( consumerKey: TwitterKey, consumerSecret: TwitterSecret, requestTokenUrl: "https://api.x.com/oauth/request_token", authorizeUrl: "https://api.x.com/oauth/authorize", accessTokenUrl: "https://api.x.com/oauth/access_token" ) let safariHandler = SafariURLHandler(viewController: self, oauthSwift: oauthswift!) safariHandler.factory = { url in return SFSafariViewController(url: url) } safariHandler.presentCompletion = { [weak self] in self?.hud.hide(animated: false) } safariHandler.dismissCompletion = { debugPrint("dismiss") } hud.show(animated: false) oauthswift?.authorizeURLHandler = safariHandler oauthswift?.authorize(withCallbackURL: TwitterAuthScheme, completionHandler: {[weak self] result in switch result { case .success(let (_, _, parameters)): if let userid = parameters["user_id"] as? String, let userName = parameters["screen_name"] as? String { debugPrint("login twitter userid: \(userid) name: \(userName)") } break case .failure(let error): self?.view.makeToast(error.localizedDescription) } }) ### OAuth Provider? (Twitter, Github, ..): Twitter ### OAuth Version: - [ ] Version 1 - [*] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [*] CocoaPods - [ ] Swift Package Manager - [ ] Manually ### Library version: - [ ] head - [ ] v2.1.0 - [ *] v2.2.0 - [ ] v1.4.1 - [ ] other: (Please fill in the version you are using.) ### Xcode version: - [ ] 11.4 (Swift 5.2) - [ ] 11.x (Swift 5.1) - [ *] 15.4 (Swift 5.5) - [ ] other: (Please fill in the version you are using.) - [ ] objective c
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#472
No description provided.