[GH-ISSUE #575] Safari showing error as 404 #377

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

Originally created by @kiran4991 on GitHub (Feb 12, 2020).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/575

We have developed our own authorization sever, I added its authorizeUrl in my code and tried to redirect on that URL using the given options (i.e. webview, SFSafariViewController, Safari browser). But I am still getting an issue going from authorizeUrl to landing page as 404
**404. That’s an error.

The requested URL /auth/login was not found on this server. That’s all we know.**
This is my code

func authenticateUsingSSOUsingOur(){
        self.loginBtn.setTitle("Authorizing..", for: .normal)
        self.oauthswift = OAuth2Swift(
            consumerKey:    "******",
            consumerSecret: "******",
            authorizeUrl:   "https://devservices.qpathways.com/auth/oauth/authorize",
            accessTokenUrl: "https://devservices.qpathways.com/auth/oauth/token",
            responseType:   "token"
        )
        let safari = SafariURLHandler(viewController: self, oauthSwift:self.oauthswift!)
        safari.delegate = self
        oauthswift?.authorizeURLHandler = safari
        let state = generateState(withLength: 20)
        _ = oauthswift?.authorize(
            withCallbackURL: URL(string: "UsingOAuthSwiftPod://oauth/callback")!,
            scope: "", state:state,
            success: { credential, response, parameters in
                print("TOKEN")
                dump(credential)
                print(credential.oauthToken)
                self.tokenLbl.text = credential.oauthToken
                self.loginBtn.isHidden = true
                self.logoutBtn.isHidden = false
                UserDefaults.standard.set(credential.oauthToken, forKey: ViewController.AUTH2TOKEN)
        },
            failure: { error in
                print(error.localizedDescription)
        }
        )
    }

OAuth Provider. - OAuth2

OAuth Version:

  • Version 1
  • [x ] Version 2

OS (Please fill the version) :

  • iOS :
  • [x ] OSX :
  • TVOS :
  • WatchOS :

Installation method:

  • Carthage
  • CocoaPods
  • Swift Package Manager
  • Manually

Library version:

  • head
  • v2.1.0
  • v2.0.0
  • v1.4.1
  • v1.2 (Swift 4.0)
  • other: (Please fill in the version you are using.)

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 @kiran4991 on GitHub (Feb 12, 2020). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/575 We have developed our own authorization sever, I added its authorizeUrl in my code and tried to redirect on that URL using the given options (i.e. webview, SFSafariViewController, Safari browser). But I am still getting an issue going from authorizeUrl to landing page as 404 **404. That’s an error. The requested URL /auth/login was not found on this server. That’s all we know.** This is my code ```swift func authenticateUsingSSOUsingOur(){ self.loginBtn.setTitle("Authorizing..", for: .normal) self.oauthswift = OAuth2Swift( consumerKey: "******", consumerSecret: "******", authorizeUrl: "https://devservices.qpathways.com/auth/oauth/authorize", accessTokenUrl: "https://devservices.qpathways.com/auth/oauth/token", responseType: "token" ) let safari = SafariURLHandler(viewController: self, oauthSwift:self.oauthswift!) safari.delegate = self oauthswift?.authorizeURLHandler = safari let state = generateState(withLength: 20) _ = oauthswift?.authorize( withCallbackURL: URL(string: "UsingOAuthSwiftPod://oauth/callback")!, scope: "", state:state, success: { credential, response, parameters in print("TOKEN") dump(credential) print(credential.oauthToken) self.tokenLbl.text = credential.oauthToken self.loginBtn.isHidden = true self.logoutBtn.isHidden = false UserDefaults.standard.set(credential.oauthToken, forKey: ViewController.AUTH2TOKEN) }, failure: { error in print(error.localizedDescription) } ) } ``` **OAuth Provider. - OAuth2** ### OAuth Version: - [ ] Version 1 - [x ] Version 2 ### OS (Please fill the version) : - [x] iOS : - [x ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [x] CocoaPods - [ ] Swift Package Manager - [ ] Manually ### Library version: - [ ] head - [ ] v2.1.0 - [ ] v2.0.0 - [ ] v1.4.1 - [x] v1.2 (Swift 4.0) - [ ] other: (Please fill in the version you are using.) ### 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:12 +03:00
Author
Owner

@phimage commented on GitHub (Feb 12, 2020):

I you have access to the server, you can look at access log or error log
see the request done to your server and why the server send 404

if you receive anything "UsingOAuthSwiftPod://oauth/callback" ? did your application defined this scheme? as describe in the readme

<!-- gh-comment-id:585234549 --> @phimage commented on GitHub (Feb 12, 2020): I you have access to the server, you can look at access log or error log see the request done to your server and why the server send 404 if you receive anything "UsingOAuthSwiftPod://oauth/callback" ? did your application defined this scheme? as describe in the readme
Author
Owner

@kiran4991 commented on GitHub (Feb 12, 2020):

Yes I set url scheme for the same at server side and client side also. https://devservices.qpathways.com/auth/oauth/authorize
This url is hit properly on chrome browser from externally (for testing purpose). but when I hit the same url from safari, I am getting an above error

<!-- gh-comment-id:585237243 --> @kiran4991 commented on GitHub (Feb 12, 2020): Yes I set url scheme for the same at server side and client side also. https://devservices.qpathways.com/auth/oauth/authorize This url is hit properly on chrome browser from externally (for testing purpose). but when I hit the same url from safari, I am getting an above error
Author
Owner

@phimage commented on GitHub (Jul 11, 2020):

no more information and no message since month, I close

<!-- gh-comment-id:657014710 --> @phimage commented on GitHub (Jul 11, 2020): no more information and no message since month, I close
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#377
No description provided.