Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication through Uber native apps #293

Merged
merged 5 commits into from
Mar 28, 2024

Conversation

mohssenfathi
Copy link
Contributor

Description

This PR implements two major features:

  • Native authentication through 1P Uber apps
  • Redirect URI handling

Native authentication

Depending on the supplied configuration, the implementer may want auth to occur from inside the Uber app, as opposed to internal to the SDK in an embedded web browser.

Pulling from the code comments:

There are three possible destinations for auth through this method:
    1. The native Uber app
    2. The OS supplied Safari browser
    3. In app auth through ASWebAuthenticationSession

 This method will run through the desired native app destinations supplied in `appPriority`.
 For each one it will:
    * Use the configuration provider to determine if the app is installed, using UIApplication's openUrl. If the app's scheme has not been registered in the Info.plist and is not queryable it will default to true and continue with the auth flow. If it is registered but not installed, we will continue to the next app.
    * Build a universal link specific to the current app destination
    * Attempt to launch the app using the `applicationLauncher`. If the app is installed, the native app should be launched (1), if not the OS supplied browser will be launched (2)

If all app destinations have been exhausted and no url has been launched we fall back to in app auth (3)

Redirect URI handling

After authenticating in the native app, the success/failure response will be sent back to the calling app via deeplink. This then needs to be forwarded to the lib via the UberAuth.handle() method.
Logic is fairly simple here, we parse the response url using AuthorizationCodeResponseParser and call the store completion with the result.

Testing

Manually

Prerequisite: Have at least one of Uber, UberEats, or UberDriver installed

  • Update the Client ID in the sample app's Info.plist to 9QZcD_Ki6NbhGCrVXSUHCxfevm-C9Khj
  • Build/run the sample app
  • Select Native from the Destination selector
  • Tap Login
    App should deep link to the 1P uber client then return to the sample app with the authorization code

Unit tests

Unit tests added for all logic heavy classes

Video

native.MP4

@mohssenfathi mohssenfathi marked this pull request as ready for review March 22, 2024 19:07
@renan-ssoares renan-ssoares self-requested a review March 26, 2024 19:43
Copy link

@alanpaivaa alanpaivaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple nits, lgtm overall

@mohssenfathi mohssenfathi merged commit b1a8832 into uber:2.x Mar 28, 2024
4 checks passed
@mohssenfathi mohssenfathi deleted the native-auth branch March 28, 2024 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants