Skip to content

Commit

Permalink
Merge pull request #245 from uber/2.x
Browse files Browse the repository at this point in the history
Merging 2.x into main
  • Loading branch information
lalwani authored Jun 13, 2024
2 parents b9db7e0 + 37087ab commit d7560f6
Show file tree
Hide file tree
Showing 129 changed files with 4,259 additions and 642 deletions.
28 changes: 5 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
java-version: '17'
- name: Lint and Unit tests
run: ./gradlew check --stacktrace
- name: Upload lint and test reports
Expand All @@ -25,12 +25,11 @@ jobs:
path: |
./core-android/build/reports
./rides-android/build/reports
test:
runs-on: macOS-latest # enables hardware acceleration in the virtual machine, required for emulator testing
strategy:
matrix:
api-level: [ 21, 23, 26 ]
api-level: [ 26, 30, 33 ]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -40,24 +39,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
- name: Emulator tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: google_apis
arch: x86
disable-animations: true
script: ./gradlew connectedCheck --stacktrace
- name: Upload instrumented test reports
if: always()
uses: actions/upload-artifact@v2
with:
name: test-reports
path: |
./core-android/build/reports
./rides-android/build/reports
java-version: '17'
upload-snapshots:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
Expand All @@ -73,9 +55,9 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
java-version: '17'
- name: Upload snapshots
run: ./gradlew uploadArchives --stacktrace
run: ./gradlew publish --stacktrace
env:
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SonatypeUsername }}
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SonatypePassword }}
79 changes: 79 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Migration Guide from Old SDK

We've simplified the SDK for consumers by providing a single point of entry. Information passing from the client app to the library is now divided into two parts:

1. **Static Information**: Provided as a one-time configuration with the `sso_config.json` file.
2. **Dynamic Information**: Contains parameters that can change over time, such as the type of flow needed, prefill information, use of SSO, or in-app authentication.

For detailed SDK integration documentation, please refer to the [authentication guide](https://github.com/uber/rides-android-sdk/tree/2.x/authentication).

This guide focuses on modifying your codebase when migrating from the older 0.10.X version of the SDK to the 2.X version.

## Steps to Follow:

### 1. Providing Application Information
- Remove `UBER_CLIENT_ID` and `UBER_REDIRECT_URI` entries from the `gradle.properties` file.
- Create a `sso_config.json` file in your application's `res/raw` folder with the following details:

```json
{
"client_id": "YOUR_CLIENT_ID",
"redirect_uri": "YOUR_APPLICATION_ID.uberauth://redirect",
"scope": "YOUR_SCOPES COMMA SEPARATED"
}
```

### 2. Deprecating `SessionConfiguration` Object
- Remove references to the `SessionConfiguration` object built like this:

```java
SessionConfiguration configuration = new SessionConfiguration.Builder()
.setClientId(CLIENT_ID)
.setRedirectUri(REDIRECT_URI)
.setScopes(Arrays.asList(Scope.PROFILE, Scope.RIDE_WIDGETS))
.setProfileHint(new ProfileHint
.Builder()
.email("john@doe.com")
.firstName("John")
.lastName("Doe")
.phone("1234567890")
.build())
.build();
```

- Instead, use `AuthContext`:

```java
AuthContext authContext = new AuthContext(
new AuthDestination.CrossAppSso(),
new AuthType.PKCE(),
new PrefillInfo(
"john@doe.com",
"John",
"Doe",
"1234567890"
)
);
```

### 3. Replace `LoginManager` with `UberAuthClient`

Replace

```java
LoginManager loginManager = new LoginManager(accessTokenStorage,
new SampleLoginCallback(),
configuration,
CUSTOM_BUTTON_REQUEST_CODE);
loginManager.login(LoginSampleActivity.this);
```
with

```java
UberAuthClient uberAuthClient = new UberAuthClientImpl();
uberAuthClient.authenticate(LoginSampleActivity.this, authContext);
```

### 4. Custom buttons (Future)

The Uber custom buttons provide apis for `setSessionConfiguration()` `setCallback()` and `setRequestCode()` with the changes in the authentication module we will not be needing these anymore as there will be only one entry point for authentication module of the sdk
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ SessionConfiguration config = new SessionConfiguration.Builder()
.build();
```
## Ride Request Deeplink
The Ride Request Deeplink provides an easy to use method to provide ride functionality against
The Ride Request Deeplink provides an easy to use method to provide ride functionality against
the install Uber app or the mobile web experience.


Without any extra configuration, the `RideRequestDeeplink` will deeplink to the Uber app. We
Without any extra configuration, the `RideRequestDeeplink` will deeplink to the Uber app. We
suggest passing additional parameters to make the Uber experience even more seamless for your users. For example, dropoff location parameters can be used to automatically pass the user’s destination information over to the driver:

```java
Expand All @@ -68,9 +68,9 @@ RideRequestDeeplink deeplink = new RideRequestDeeplink.Builder(context)
```

### Deeplink Fallbacks
The Ride Request Deeplink will prefer to use deferred deeplinking by default, where the user is
taken to the Play Store to download the app, and then continue the deeplink behavior in the app
after installation. However, an alternate fallback may be used to prefer the mobile web
The Ride Request Deeplink will prefer to use deferred deeplinking by default, where the user is
taken to the Play Store to download the app, and then continue the deeplink behavior in the app
after installation. However, an alternate fallback may be used to prefer the mobile web
experience instead.

To prefer mobile web over an app installation, set the fallback on the builder:
Expand Down Expand Up @@ -128,7 +128,7 @@ For a button with a white background and black text:
uber:ub__style="white"/>
```

To specify the mobile web deeplink fallback over app installation when using the
To specify the mobile web deeplink fallback over app installation when using the
`RideRequestButton`:

```java
Expand Down Expand Up @@ -191,11 +191,11 @@ To use SDK features, two configuration details must be set on the Uber Developer

1. Sign into to the [developer dashboard](https://developer.uber.com/dashboard)

1. Register a redirect URI to be used to communication authentication results. The default used
1. Register a redirect URI to be used to communication authentication results. The default used
by the SDK is in the format of `applicationId.uberauth://redirect`. ex: `com.example
.uberauth://redirect`. To configure the SDK to use a different redirect URI, see the steps below.
1. To use Single Sign On you must register a hash of your application's signing certificate in the
.uberauth://redirect`. To configure the SDK to use a different redirect URI, see the steps below.

1. To use Single Sign On you must register a hash of your application's signing certificate in the
Application Signature section of the settings page of your application.

To get the hash of your signing certificate, run this command with the alias of your key and path to your keystore:
Expand Down Expand Up @@ -244,14 +244,14 @@ With Version 0.8 and above of the SDK, the redirect URI is more strongly enforce
standards [IETF RFC](https://tools.ietf.org/html/draft-ietf-oauth-native-apps-12).

The SDK will automatically created a redirect URI to be used in the oauth callbacks with
the format "applicationId.uberauth://redirect", ex "com.example.app.uberauth://redirect". **This URI must be registered in
the format "applicationId.uberauth://redirect", ex "com.example.app.uberauth://redirect". **This URI must be registered in
the [developer dashboard](https://developer.uber.com/dashboard)**

If this differs from the previous specified redirect URI configured in the SessionConfiguration,
If this differs from the previous specified redirect URI configured in the SessionConfiguration,
there are a few options.

1. Change the redirect URI to match the new scheme in the configuration of the Session. If this
is left out entirely, the default will be used.
1. Change the redirect URI to match the new scheme in the configuration of the Session. If this
is left out entirely, the default will be used.

```java
SessionConfiguration config = new SessionConfiguration.Builder()
Expand All @@ -276,10 +276,10 @@ filter. Register this custom URI in the developer dashboard for your application
</activity>
```

3. If using [Authorization Code Flow](https://developer.uber.com/docs/riders/guides/authentication/user-access-token), you will need to configure your server to redirect to
3. If using [Authorization Code Flow](https://developer.uber.com/docs/riders/guides/authentication/user-access-token), you will need to configure your server to redirect to
the Mobile Application with an access token either via the generated URI or a custom URI as defined in steps 1 and 2.

The Session should be configured to redirect to the server to do a code exchange and the login
The Session should be configured to redirect to the server to do a code exchange and the login
manager should indicate the SDK is operating in the Authorization Code Flow.

```java
Expand All @@ -291,17 +291,17 @@ loginManager.setAuthCodeFlowEnabled(true);
loginManager.login(this);

```
Once the code is exchanged, the server should redirect to a URI in the standard OAUTH format of
Once the code is exchanged, the server should redirect to a URI in the standard OAUTH format of
`com.example.app.uberauth://redirect#access_token=ACCESS_TOKEN&token_type=Bearer&expires_in=TTL&scope=SCOPES&refresh_token=REFRESH_TOKEN`
for the SDK to receive the access token and continue operation.``


##### Authorization Code Flow


The default behavior of calling `LoginManager.login(activity)` is to activate Single Sign On,
and if SSO is unavailable, fallback to Implicit Grant if privileged scopes are not requested,
otherwise redirect to the Play Store. If you require Authorization Code Grant, set `LoginManager.setAuthCodeFlowEnabled(true)`
The default behavior of calling `LoginManager.login(activity)` is to activate Single Sign On,
and if SSO is unavailable, fallback to Implicit Grant if privileged scopes are not requested,
otherwise redirect to the Play Store. If you require Authorization Code Grant, set `LoginManager.setAuthCodeFlowEnabled(true)`
to use the Authorization Code Flow as the fallback mechanism instead of Implicit Grant or redirecting to the Play Store (regardless of scope).
Implicit Grant will allow access to all non-privileged scopes (and will not grant a refresh token), whereas the other options grant access to privileged scopes. [Read more about scopes](https://developer.uber.com/docs/scopes).

Expand Down Expand Up @@ -448,9 +448,9 @@ For full documentation about our API, visit our Developer Site.

## Contributing

We :heart: contributions. Found a bug or looking for a new feature? Open an issue and we'll
respond as fast as we can. Or, better yet, implement it yourself and open a pull request! We ask
that you open an issue to discuss feature development prior to undertaking the work and that you
We :heart: contributions. Found a bug or looking for a new feature? Open an issue and we'll
respond as fast as we can. Or, better yet, implement it yourself and open a pull request! We ask
that you open an issue to discuss feature development prior to undertaking the work and that you
include tests to show the bug was fixed or the feature works as expected.

## MIT Licensed
Loading

0 comments on commit d7560f6

Please sign in to comment.