Search code examples
swiftuber-api

Uber SSO Login error Swift 2.3


I'm trying integrate Uber into my app

Use this code to add uber login button:

    uberScopes = [.History, .Profile, .HistoryLite, .Places, .RideWidgets, .AllTrips, .Request, .RequestReceipt]
    uberLoginManager = LoginManager(loginType: .Native)
    let loginButton = LoginButton(frame: CGRectZero, scopes: uberScopes!, loginManager: uberLoginManager)
    loginButton.presentingViewController = self
    loginButton.delegate = self
    loginButton.frame = logoutBgView.bounds
    loginButton.autoresizingMask =
        [.FlexibleWidth, .FlexibleHeight]
    logoutBgView.addSubview(loginButton)

and delegate

 func loginButton(button: LoginButton, didLogoutWithSuccess success: Bool) {
        if success {
            showMessage("Logout")
        }
    }

    func loginButton(button: LoginButton, didCompleteLoginWithToken accessToken: AccessToken?, error: NSError?) {
        if let _ = accessToken {
            showMessage("Saved access token!")
        } else if let error = error {
            showMessage(error.localizedDescription)
        } else {
            showMessage("Error")
        }
    }

Code not working for native type login in app. When i tap on "Sign in" redirect to safari then app store (i have uber app installed) and not go to uber app to allow or deny scopes that i need. I was set redirect URI, client ID, display name, server token.

Someone can help me?

EDIT1: Log error:

2016-12-28 17:47:40.383 RexpenseSandbox[40681:530203] -canOpenURL: failed for URL: "uberauth://connect?third_party_app_name=xxxxxxxxxx &callback_uri_string=xxxxxxxxxxxxxxx&client_id=kEA5TjaXpT7QeicsvWLIYS-L3eWBpVZq&login_type=default&scope=history%20profile%20history_lite%20places%20ride_widgets%20all_trips%20request%20request_receipt&sdk=ios&sdk_version=0.6.0" - error: "(null)"

EDIT2 - I'm testing a build at Testflight. When i tap on sign in button open uber but isn't appear OAuth only open safari with RedirectURI


Solution

  • Based on that error, it looks like you didn't add the necessary url schemes to your info.plist's Application Query Schemes. Make sure you have the following in your info.plist:

    <key>LSApplicationQueriesSchemes</key>
    <array>                                           
    <string>uber</string>
    <string>uberauth</string>
    </array>
    

    You can read the tutorial for configuring the SDK for some more info