uber / rides-ios-sdk

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

Implement Token exchange request #295

Closed mohssenfathi closed 4 months ago

mohssenfathi commented 4 months ago

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

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