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

Implement Token exchange request #295

Merged
merged 2 commits into from
Apr 5, 2024
Merged

Conversation

mohssenfathi
Copy link
Contributor

Description

Adds support for exchanging the authorization code returned from the /authorize endpoint for a token using the /token endpoint

Completion Handling

I "intercepted" the completion handler passed into the execute method and exchange the token there if needed. I manually verified using the memory debugger that instances were not retained, but please double check me.

Request -> NetworkRequest

There was a naming conflict between UberAuth.Request and UberRides.Request, and I couldn't specify the namespace because I named a class (UberAuth) the same as the framework name 😅. So this was breaking mocks.
I renamed Request to NetworkRequest to fix this. If UberRides is removed in the future we could change the name back.

TokenRequest

This should be similar to the other requests, ParRequest or AuthorizeRequest. It makes a request to the token endpoint and decodes a Token response conforming to the OAuth standard.

Testing

Unit Tests

Unit tests added for new auth provider logic.

Manual Testing

  • Update clientID 9QZcD_Ki6NbhGCrVXSUHCxfevm-C9Khj in the sample app's Info.plist
  • Toggle the Exchange Auth Code for Token to on
  • Login and verify a token (and no auth code) is sent in the response

Video

Token Exchange No Token Exchange
https://github.com/uber/rides-ios-sdk/assets/5241321/66211556-e6dc-4e4d-94ff-d7af4cfea9ef https://github.com/uber/rides-ios-sdk/assets/5241321/7d99ca2e-721b-4b9f-840f-1079036f17d3

@mohssenfathi mohssenfathi marked this pull request as ready for review April 2, 2024 21:30
@mohssenfathi mohssenfathi merged commit 97bbae3 into uber:2.x Apr 5, 2024
4 checks passed
@mohssenfathi mohssenfathi deleted the token-exchange branch April 5, 2024 16:20
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