Skip to content

Add UberEnvironment to allow 3Ps to target sandbox vs production#268

Open
partha-uber wants to merge 1 commit intouber:mainfrom
partha-uber:sirker-sandbox-config
Open

Add UberEnvironment to allow 3Ps to target sandbox vs production#268
partha-uber wants to merge 1 commit intouber:mainfrom
partha-uber:sirker-sandbox-config

Conversation

@partha-uber
Copy link
Copy Markdown
Contributor

Summary

Adds support for 3P developers to configure which Uber auth environment to target when integrating with the Android SDK.

Previously the SDK hardcoded auth.uber.com across all auth flows (/authorize, /par, /token) with no way to redirect to sandbox for testing.

Changes:

  • Add UberEnvironment enum to UriConfig with PRODUCTION and SANDBOX cases, each mapping to its base URL
  • Add optional environment field to AuthContext (defaults to PRODUCTION — fully backwards-compatible)
  • Thread environment through AuthService.create(), AuthProvider, SsoLinkFactory, and UniversalSsoLink so all three OAuth endpoints respect the configured environment

Usage:

// Production (default — no change for existing integrations)
val authContext = AuthContext()

// Sandbox
val authContext = AuthContext(environment = UriConfig.UberEnvironment.SANDBOX)

Test Plan

  • Added unit tests verifying PRODUCTION and SANDBOX URLs for assembleUri() and getAuthHost()
  • Added unit tests verifying AuthContext defaults to PRODUCTION and SANDBOX can be set
  • Added unit test verifying authentication flow succeeds with SANDBOX environment
  • All existing tests continue to pass unchanged

Related

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 (1M context) noreply@anthropic.com

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 5, 2026

CLA assistant check
All committers have signed the CLA.

@partha-uber partha-uber force-pushed the sirker-sandbox-config branch from 3b41ebb to bd17c80 Compare May 6, 2026 00:53
Adds a new UberEnvironment enum (PRODUCTION/SANDBOX) and threads it
through the auth flow so 3P integrators can target sandbox-login.uber.com
for testing without changing their production integration.

- Add UberEnvironment enum to UriConfig with PRODUCTION and SANDBOX base URLs
- Add optional environment field to AuthContext (defaults to PRODUCTION)
- Thread environment into AuthService.create(), UniversalSsoLink, and SsoLinkFactory
- Add unit tests covering both environments and backwards-compatibility default

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@partha-uber partha-uber force-pushed the sirker-sandbox-config branch from bd17c80 to 20c7eef Compare May 6, 2026 01:10
@partha-uber partha-uber requested a review from lalwani May 6, 2026 01:18
}

@Test
fun `test authenticate with SANDBOX environment succeeds`() = runTest {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This test doesn't ensure that the environment is actually sandbox

private val ssoConfig: SsoConfig,
private val authContext: AuthContext,
private val appDiscovering: AppDiscovering,
private val environment: UriConfig.UberEnvironment = UriConfig.UberEnvironment.PRODUCTION,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this environment is saved separately from what was passed in via authContext. There should be just 1 source of truth

import com.uber.sdk2.core.BuildConfig
import com.uber.sdk2.core.config.UriConfig.EndpointRegion.DEFAULT
import com.uber.sdk2.core.config.UriConfig.Environment.API
import com.uber.sdk2.core.config.UriConfig.Environment.AUTH
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We probably don't need Environment anymore. If yes, please remove it.

val authType: AuthType = AuthType.PKCE(),
val prefillInfo: PrefillInfo? = null,
val prompt: Prompt? = null,
val environment: UriConfig.UberEnvironment = UriConfig.UberEnvironment.PRODUCTION,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

add documentation for this new parameter

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.

3 participants