Skip to content

Commit a1fc6f0

Browse files
authored
Merge pull request #319 from mohssenfathi/2.0.0-migration-guide
Add migration guide for 2.0.0
2 parents ce00389 + 1442b74 commit a1fc6f0

File tree

2 files changed

+174
-0
lines changed

2 files changed

+174
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
This library allows you to authenticate with Uber services and interact with the Uber Rides API in your iOS application.
44

5+
## Migrating to 2.0.0
6+
Check the [Migration Guide](./documentation/migration-guide-2.0.0.md) for instructions on how to upgrade.
7+
58
## Requirements
69

710
- iOS 14.0+
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Uber iOS SDK 2.0.0 - Migration Guide
2+
The Uber Rides SDK has been revamped and renamed to the Uber iOS SDK. Among other things, this new release includes a simplified API, better security for mobile OAuth, and updated platform support.
3+
4+
There are a few breaking changes that must be handled when updating the SDK. This guide will help you navigate the major code changes necessary to make the upgrade.
5+
6+
## New + Updated Features
7+
### Swift Package Manager Support
8+
Swift Package Manager is now the preferred way to integrate the Uber iOS SDK. Support for other third party package managers has been dropped for this release.
9+
10+
### Improved API
11+
Authenticating with Uber has now been moved behind a simplified API. Now, less setup and state management is required from the caller.
12+
13+
### Auth Code Grant Flow + PKCE
14+
The Authorization Code Grant Flow is now the default method for requesting auth credentials. In addition, support for PKCE and client access token exchange has been added.
15+
16+
Support for the Implicit Grant Flow has been removed.
17+
18+
### Prefill User Information
19+
A convenient growth feature has been added for in app authentication. Supply optional user information to be prefilled on the signup + login page when asking the user to authenticate.
20+
21+
### Sample App Improvements
22+
A brand new [sample app](../examples/UberSDK/README.md) has been provided. Use it as a playground to test your app's functionality.
23+
24+
## Migrating from 0.1x
25+
26+
### Info.plist Keys
27+
The keys used to identify your app's credentials have changed in this release.
28+
29+
Previously, top-level `UberClientID` and `UberDisplayName` keys were used.
30+
```
31+
<key>UberClientID</key>
32+
<string>[ClientID]</string>
33+
<key>UberServerToken</key>
34+
<string>[Server Token]</string>
35+
<key>UberDisplayName</key>
36+
<string>[App Name]</string>
37+
<key>LSApplicationQueriesSchemes</key>
38+
<array>
39+
<string>uber</string>
40+
<string>uberauth</string>
41+
</array>
42+
```
43+
44+
These keys have been moved under a parent `Uber` key.
45+
46+
47+
Note that `LSApplicationQueriesSchemes` remains top level, however:
48+
49+
* UberClientID -> Uber/ClientID
50+
* UberDisplayName -> Uber/DisplayName
51+
52+
53+
```
54+
<key>LSApplicationQueriesSchemes</key>
55+
<array>
56+
<string>uber</string>
57+
<string>uberauth</string>
58+
<string>ubereats</string>
59+
<string>uberdriver</string>
60+
</array>
61+
<key>Uber</key>
62+
<dict>
63+
<key>ClientID</key>
64+
<string>[Client ID]</string>
65+
<key>DisplayName</key>
66+
<string>[App Name]</string>
67+
</dict>
68+
```
69+
70+
71+
### Authenticating
72+
73+
Previously, to initiate auth, the LoginManager was accessed directly. This can no longer be done and auth must now be initiated using the `UberAuth.login` static method.
74+
75+
Before:
76+
```
77+
let requestedScopes = [UberScope.request, UberScope.allTrips]
78+
let loginManager = LoginManager(...)
79+
80+
loginManager.login(
81+
requestedScopes: requestedScopes,
82+
presentingViewController: self
83+
) { (accessToken, error) -> () in
84+
// Use access token or handle error
85+
}
86+
```
87+
88+
After:
89+
```
90+
let context = AuthContext(
91+
authDestination: authDestination, // .native or .inApp
92+
authProvider: authProvider, // .authorizationCode
93+
prefill: prefill
94+
)
95+
96+
UberAuth.login(
97+
context: context,
98+
completion: { result in
99+
// Handle Result<Client>
100+
}
101+
)
102+
```
103+
104+
### Response Types
105+
The auth API no longer response directly with an access token. Now, the login response will come in the form of a Result type either containing a value of type `Client` or an error of type `UberAuthError`.
106+
107+
The Client type contains the following properties:
108+
| Property | Type | Description |
109+
| ------------- | ------------- | ------------- |
110+
| authorizationCode | String? | The authorization code received from the authorization server. If this property is non-nil, all other properties will be nil. |
111+
| accessToken | String? | The access token issued by the authorization server. This property will only be populated if token exchange is enabled. |
112+
| refreshToken | String? | The type of the token issued. |
113+
| tokenType | String? | The type of the token issued. |
114+
| expiresIn | Int? | A token which can be used to obtain new access tokens. |
115+
| scope | [String]? | A comma separated list of scopes requested by the client. |
116+
117+
118+
and the UberAuthError cases are defined [here](../Sources/UberAuth/Errors/UberAuthError.swift)
119+
120+
To get auth credentials in the login callback, check the authorizationCode or accessToken properties on the client object.
121+
122+
Before:
123+
```
124+
loginManager.login(
125+
requestedScopes: requestedScopes,
126+
presentingViewController: self
127+
) { (accessToken, error) -> () in
128+
print(accessToken ?? "none") // Prints the access token
129+
}
130+
```
131+
132+
After:
133+
```
134+
UberAuth.login { result in
135+
switch result {
136+
case .success(let client):
137+
print(client.accessToken ?? "none") // Prints the access token
138+
case .failure(let error):
139+
// Handle UberAuthError
140+
break
141+
}
142+
}
143+
```
144+
145+
### Handling Responses
146+
Previously, the UberAppDelegate API was used to pass through URLs entering the app. This API has been transitioned to the UberAuth interface.
147+
148+
Before:
149+
```
150+
func application(_ app: UIApplication,
151+
open url: URL,
152+
options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
153+
let handledUberURL = UberAppDelegate.shared.application(app, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation] as Any)
154+
155+
return handledUberURL
156+
}
157+
```
158+
159+
After:
160+
```
161+
func application(_ app: UIApplication,
162+
open url: URL,
163+
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
164+
165+
// If handled == true, UberAuth was able to accept the url
166+
if let handled = UberAuth.handle(url) {
167+
return true
168+
}
169+
...
170+
}
171+
```

0 commit comments

Comments
 (0)