OAuthSwift / OAuthSwift

Swift based OAuth library for iOS
MIT License
3.27k stars 591 forks source link

Safari showing error as 404 #575

Closed kiran4991 closed 4 years ago

kiran4991 commented 4 years ago

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:

OS (Please fill the version) :

Installation method:

Library version:

Xcode version:

phimage commented 4 years ago

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

kiran4991 commented 4 years ago

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

phimage commented 4 years ago

no more information and no message since month, I close