[GH-ISSUE #694] OAuthSwiftError -10 after canceling redirection to app #449

Closed
opened 2026-03-03 16:48:45 +03:00 by kerem · 3 comments
Owner

Originally created by @fbaumgart on GitHub (Feb 7, 2022).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/694

Description:

Hello,
I have implemented authorization using library as described in the examples.
Application is redirecting me to the login page in the Safari view and I am able to successfully login and be redirected to my iOS app after confirming that I want to be redirected on the popup window.
However when I don't confirm and hit 'Cancel' instead of 'Open' on this modal and navigate manually back to my app and try to login again this time confirming the redirection to my app after successful login - I get -10 OAuthSwift error.
I cannot resolve this issue, after restarting the app it works normally again, but the issue can still be reproduced.

Direct steps:

  1. User hits login button in the app
  2. Login website opens in Safari view
  3. User provides login / password and hits submit
  4. Pop-up windows shows with question if you want to open the link in the app
  5. User hits 'Cancel'
  6. User manually navigates back to app and lands again on the screen with login button
  7. User performs again steps 1 -4
  8. User hits 'Open' on the popup
  9. User is redirected successfully to the app but gets OAuthSwiftError code -10

I have already tried to delete my retained oauth2swift object but it doesn't work.

Any clues why this happens?

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

Keycloak

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.0.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)

  • 10.x (Swift 5.0)

  • other: (13.1)

  • objective c

Originally created by @fbaumgart on GitHub (Feb 7, 2022). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/694 ### Description: Hello, I have implemented authorization using library as described in the examples. Application is redirecting me to the login page in the Safari view and I am able to successfully login and be redirected to my iOS app after confirming that I want to be redirected on the popup window. However when I don't confirm and hit 'Cancel' instead of 'Open' on this modal and navigate manually back to my app and try to login again this time confirming the redirection to my app after successful login - I get -10 OAuthSwift error. I cannot resolve this issue, after restarting the app it works normally again, but the issue can still be reproduced. Direct steps: 1. User hits login button in the app 2. Login website opens in Safari view 3. User provides login / password and hits submit 4. Pop-up windows shows with question if you want to open the link in the app 5. User hits 'Cancel' 6. User manually navigates back to app and lands again on the screen with login button 7. User performs again steps 1 -4 8. User hits 'Open' on the popup 9. User is redirected successfully to the app but gets OAuthSwiftError code -10 I have already tried to delete my retained oauth2swift object but it doesn't work. Any clues why this happens? ### OAuth Provider? (Twitter, Github, ..): Keycloak ### OAuth Version: - [ ] Version 1 - [x] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [x] CocoaPods - [ ] Swift Package Manager - [ ] Manually ### Library version: - [x] head - [ ] v2.1.0 - [ ] v2.0.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) - [ ] 10.x (Swift 5.0) - [x] other: (13.1) - [ ] objective c
kerem closed this issue 2026-03-03 16:48:45 +03:00
Author
Owner

@fbaumgart commented on GitHub (Feb 7, 2022):

resolution: you need to set the oauthswift.authorizeURLHandler property :)

<!-- gh-comment-id:1031333060 --> @fbaumgart commented on GitHub (Feb 7, 2022): resolution: you need to set the oauthswift.authorizeURLHandler property :)
Author
Owner

@yaoligang123 commented on GitHub (Jun 27, 2023):

Hi @fbaumgart

resolution: you need to set the oauthswift.authorizeURLHandler property :)

How to set the oauthswift.authorizeURLHandler property :)?

Can you provide example code?Thanks.

<!-- gh-comment-id:1608882620 --> @yaoligang123 commented on GitHub (Jun 27, 2023): Hi @fbaumgart resolution: you need to set the oauthswift.authorizeURLHandler property :) How to set the oauthswift.authorizeURLHandler property :)? Can you provide example code?Thanks.
Author
Owner

@fbaumgart commented on GitHub (Jun 30, 2023):

@yaoligang123 sorry, I'm no longer in possession of this code, but documentation provides some examples and clarification:

https://github.com/OAuthSwift/OAuthSwift#handle-authorize-url

<!-- gh-comment-id:1614221664 --> @fbaumgart commented on GitHub (Jun 30, 2023): @yaoligang123 sorry, I'm no longer in possession of this code, but documentation provides some examples and clarification: https://github.com/OAuthSwift/OAuthSwift#handle-authorize-url
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#449
No description provided.