uber / uber-ios-sdk

Uber iOS SDK (beta)
https://developer.uber.com/docs
MIT License
376 stars 125 forks source link

Dubious "User cancelled the login process" errors #90

Closed regosen closed 6 years ago

regosen commented 8 years ago

(Using UberRides 0.5.2 via CocoaPods, tested on iPhone6 with iOS 9.3.4)

Immediately after obtaining a valid access token via deep link, our login methods themselves will sometimes return a nil accessToken with the following error:

com.uber.rides-ios-sdk.ridesAuthenticationError Code=25 "User cancelled the login process."

Note that I definitely did not cancel anything as the user. All I did was press "Allow". This has happened with both of the following methods (with AllTrips request):

(void)loginButton:(UBSDKLoginButton * _Nonnull)button didCompleteLoginWithToken:(UBSDKAccessToken * _Nullable)accessToken error:(NSError * _Nullable)error

[loginManager loginWithRequestedScopes:@[ UBSDKRidesScope.AllTrips ] presentingViewController: self completion: ^(UBSDKAccessToken * _Nullable accessToken, NSError * _Nullable error)

If we ignore the error and use the valid access token we had already received beforehand, everything seems ok.

jbrophy17 commented 8 years ago

Hm, looks like a possible race condition when handling the deeplink. I will investigate more

Avinodh commented 7 years ago

Hi I'm facing the exact same issue. After clicking the Uber Login Button in my app, I get redirected to the native Uber app where I click "Allow". I am redirected back to my app. However, I see the following error: Error Domain=com.uber.rides-ios-sdk.ridesAuthenticationError Code=25 "User cancelled the login process." UserInfo={NSLocalizedDescription=User cancelled the login process.}

Using Swift 3. Would appreciate any help!

Avinodh commented 7 years ago

Following up with respect to the above question @jbrophy17

runningdemo commented 7 years ago

I got the same problem here. Does anyone have any update on this? The Strange thing is I can run the Objective-C demo without this issue.

I am using:

edjiang commented 7 years ago

Hey @liaa, @Avinodh, and @regosen:

Just double checking, but did you include the deep link handlers in your AppDelegate? They should look something like this:

@available(iOS 9, *)
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {

    return RidesAppDelegate.sharedInstance.application(app, openURL: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation] as AnyObject)
}

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    return RidesAppDelegate.sharedInstance.application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation as AnyObject)
}
prgorasiya commented 6 years ago

@edjiang I am also facing this issue and also when I click on Ok from error popup Uber app doesn't redirect to my own app and when I manually open my app console logs the same error message.

But in the backend of Uber it says I authorised my app to use Uber but actually Uber app throws me this error.

Any help?

edjiang commented 6 years ago

Did you register the URL scheme in your app's info.plist?

nafetswirth commented 6 years ago

Hey @edjiang,

I'm also seeing this but only for the first time when i press the Uber Login Buttun and the system shows me the alert "x" wants to open "Uber".

After clicking allow and the redirect to my app i get:

Error Domain=com.uber.rides-ios-sdk.ridesAuthenticationError Code=25 "User cancelled the login process." UserInfo={NSLocalizedDescription=User cancelled the login process.}

Second login works fine so that makes me think it's not an issue in the configuration but i might be wrong.

edjiang commented 6 years ago

What iOS version and SDK version are you on, @nafetswirth?

nafetswirth commented 6 years ago

@edjiang SDK version is 0.8

iOS versions were 9.2, 10.2 and 11.2.1

edjiang commented 6 years ago

Hey all -- thanks for your patience on this. @lhasiuk has submitted what I believe is a fix to this problem in #222 -- will be verifying and cutting a release shortly :)

edjiang commented 6 years ago

Fix is published to Cocoapods, 0.8.1. Thanks so much for your help!

Avinodh commented 6 years ago

@edjiang Been away from this project for a while, but back to working on it. Glad to see a fix for this was just released. Will test this and see if it works in my use case. Thanks for publishing this!

MEnnabah commented 6 years ago

Hi @edjiang I am facing the same issue here. The SDK opens Uber native app, it shows "Unable to Connect", and never redirect me back. However, when I manually go back, I see the following NSError:

Error Domain=com.uber.rides-ios-sdk.ridesAuthenticationError Code=25 "User cancelled the login process." UserInfo={NSLocalizedDescription=User cancelled the login process.}

My environment is:

Podfile:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'My-Project' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for My-Project
  pod 'UberRides', '~> 0.9'  
end

AppDelegate.swift:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        _ = UberAppDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
        return true
    }

    @available(iOS 9, *)
    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
        let handledUberURL = UberAppDelegate.shared.application(app, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation] as Any)

        return handledUberURL
    }

    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        let handledUberURL = UberAppDelegate.shared.application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)

        return handledUberURL
    }

info.plist:

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

    <key>UberClientID</key>
    <string>XXXMYCLIENTIDXXX</string>

    <key>UberDisplayName</key>
    <string>MY-ProjectName</string>

        <key>UberCallbackURIs</key>
    <array>
        <dict>
            <key>UberCallbackURIType</key>
            <string>General</string>
            <key>URIString</key>
            <string>com.bundle.id://oauth/consumer</string>
        </dict>
    </array>

Please let me know if I am missing anything. Thanks

MEnnabah commented 6 years ago

^ replying to my comment above, I have successfuly solved it.

I needed to add the following to my info.plist file:

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>com.bundle.id</string>
            </array>
        </dict>
    </array>

I bieleve this is mentioned in your README.md file, but since I already have those keys in my info.plist file, adding them via plist source code won't affect them. I had to added them to the already-added keys.

shahidgeek commented 5 years ago

Uber Android Authentication with uber SDK

Solved As Uber latest SKD version 0.10 Android have this "user cancel login" bug

Please following the official link which is based on Uber SDK 0.8 where the latest one has the issue which is 0.10.

Please use sample code from below link which is 0.8 uber sdk, without "login cancel issue". Following sample for android uber sdk is 0.8.

https://github.com/uber/rides-android-sdk

Please change to this one in Manifest file for LoginRedirectReceiverActivity

<activity android:name=".auth.LoginRedirectReceiverActivity"

        android:exported="true">

        <intent-filter>

            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />

            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="com.uber.sdk.android.core.uberauth"

                android:host="redirect" />

        </intent-filter>

    </activity>

Rest is update your code with client id = your_client_id server_token = your_server_token redirect_uri = com.uber.sdk.android.rides.samples.uberauth://redirect

Happy Coding :)

padsalanilay commented 4 years ago

Hi @edjiang, I am facing a similar issue. My app gets redirect to the Uber app and right after that it again gets redirected back, and I receive "User canceled the login process" error. I have added code to AppDelegate and also have added required keys to info.plist I am using a sandbox and have enabled it in a delegate.

ios - 13.5 cocoa UberRides - 0.13

Thanks