uber / rides-ios-sdk

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

Adds support for Auth Code Grant Flow #290

Closed mohssenfathi closed 5 months ago

mohssenfathi commented 5 months ago

Description

This PR adds support for the auth code grant flow via In App login. This will allow integrators to request an authorization code via Uber through ASWebAuthenticationSession only (native coming in the next PR).

AuthorizeRequest / Request

Added a request class that is specific to auth related requests. This will also be used for PAR and any other auth types in the future. There is an existing Request class in UberCore, however it is primarily used for Rides requests which may be stripped in the future.

AuthenticationSession

A wrapper around ASWebAuthenticationSession to make launching and handling the result easier.

AuthorizationCodeAuthProvider

The main logic for the auth code grant flow. This class will be responsible for fetching request dependencies and making the network request to Uber auth. Eventually it will also manage initiating native login and exchanging auth code for tokens.

PlistParser

A helper class to fetch values from the Info.plist

Testing

Sample App

The sample app has been updated to allow testing the new flow. To do so you will need to set a test ClientID and Redirect URL in the Info.plist of the sample app. You can use the following values:

ClientID RedirectURI
9QZcD_Ki6NbhGCrVXSUHCxfevm-C9Khj com.uber.UberSDK://oauth/consumer

Unit tests

Unit tests were added for all logic heavy classes minus AuthenticationSession. ASWebAuthenticationSession is not easily testable. I will add partial testing to this class later on.

Video

https://github.com/uber/rides-ios-sdk/assets/5241321/51da7b6f-066f-45ec-a8d9-2972967d5cbd