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

Token Storage + UI #298

Merged
merged 3 commits into from
May 9, 2024
Merged

Token Storage + UI #298

merged 3 commits into from
May 9, 2024

Conversation

mohssenfathi
Copy link
Contributor

Description

This PR does two main things:

  1. Adds a new TokenManager and supporting KeychainUtility so that we can save access tokens upon successful authentication.
  2. Adds replacement UI elements for the UberButton + LoginButton.

Changes

Supported platforms v13 -> v15

Bumped the minimum supported platform version to 15 to support the UIButton APIs. Platform adoption should be at a high enough level to support this. Also, this is in line with the 1P Uber app's min OS version.

AccessToken

A new AccessToken struct has be created to accompany the new Auth stack. The old one has been marked as DEPRECATED, but the logic should be similar.

Deprecated Classes

Legacy AccessToken and TokenManager have been marked as deprecated and call sites have been updated. There will be a later PR that migrates these call sites to the new classes.

Saving AccessToken

AuthorizationCodeAuthProvider now contains logic to save the AccessToken to the keychain after successfully exchanging authorization code for access token.

TokenManager + KeychainUtility

These are similar to the existing ones, with some improvements to the API. They now accept any objects conforming to the Codable protocol instead of NSCoding. Other logic should remain the same.

UberButton + LoginButton

The existing UberButton and LoginButton classes have been replaced with updated APIs that are now available. The UI and logic remains the same. Some resources including colors and images have been added to the bundle to support the new buttons.

Testing

Unit Tests

Unit tests have been added for new logic around token storage.

Manual Testing

The UberButton/LoginButton has been added to the sample app for manual testing purposes.

@mohssenfathi mohssenfathi marked this pull request as ready for review May 1, 2024 23:35
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.

Thanks for addressing the comments

}

private func login() {
let defaultContext = AuthContext(

Choose a reason for hiding this comment

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

NIT: could be moved to a constant at class level.

)
)
let context = dataSource?.authContext(self) ?? defaultContext
UberAuth.login(context: context) { [weak self] result in

Choose a reason for hiding this comment

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

NIT: weak self likely not needed, since UberAuth is being referred statically

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Will fix in the next PR.

@mohssenfathi mohssenfathi merged commit 8f927ed into uber:2.x May 9, 2024
4 checks passed
@mohssenfathi mohssenfathi deleted the token-storage branch May 9, 2024 16:34
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