Skip to content

Conversation

@subhankarmaiti
Copy link
Contributor

@subhankarmaiti subhankarmaiti commented Jul 29, 2025

Adds support for Multi-Resource Refresh Token (MRRT), enabling applications to obtain access tokens for multiple APIs using a single refresh token.

New Public APIs

getApiCredentials

Retrieves access tokens for a specific API audience.

getApiCredentials(
  audience: string,
  scope?: string,
  minTtl?: number,
  parameters?: Record<string, any>
): Promise<ApiCredentials>

clearApiCredentials

Clears cached credentials for a specific audience.

clearApiCredentials(audience: string): Promise<void>

ApiCredentials Type

interface ApiCredentials {
  accessToken: string;
  tokenType: string;
  expiresAt: number;
  scope?: string;
}

Platform Support

Platform Status
Android
iOS
Web

Usage

const { getApiCredentials, clearApiCredentials } = useAuth0();

// Get API credentials
const credentials = await getApiCredentials('https://api.example.com', 'read:data');

// Clear API credentials
await clearApiCredentials('https://api.example.com');

Web Configuration

On the web platform, you must enable MRRT support explicitly in the Auth0Provider:

<Auth0Provider
  domain="your-domain.auth0.com"
  clientId="your-client-id"
  useMrrt={true}
>
  {children}
</Auth0Provider>

Prerequisites

  • MRRT enabled on Auth0 tenant
  • offline_access scope requested during login

@subhankarmaiti subhankarmaiti reopened this Sep 9, 2025
@subhankarmaiti subhankarmaiti marked this pull request as ready for review September 9, 2025 09:14
@subhankarmaiti subhankarmaiti requested a review from a team as a code owner September 9, 2025 09:14
@subhankarmaiti subhankarmaiti reopened this Sep 9, 2025
subhankarmaiti and others added 18 commits September 10, 2025 20:02
@subhankarmaiti subhankarmaiti changed the title feat: added support for MRRT on Android/iOS feat: add Multi-Resource Refresh Token (MRRT) support Nov 30, 2025
Copilot finished reviewing on behalf of pmathew92 December 1, 2025 09:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive Multi-Resource Refresh Token (MRRT) support across all platforms (iOS, Android, and Web), enabling applications to obtain access tokens for multiple APIs using a single refresh token.

Key Changes:

  • Introduces two new public APIs: getApiCredentials() and clearApiCredentials()
  • Adds the ApiCredentials type to represent API-specific credentials
  • Implements MRRT functionality on iOS, Android, and Web platforms with proper error handling and caching

Reviewed changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/types/common.ts Adds ApiCredentials type definition with access token, token type, expiration, and scope
src/types/parameters.ts Extends RefreshTokenParameters with optional audience field for MRRT support
src/types/platform-specific.ts Adds web-specific options useMrrt and useRefreshTokensFallback
src/specs/NativeA0Auth0.ts Adds TurboModule specs for getApiCredentials and clearApiCredentials methods
src/core/models/ApiCredentials.ts Implements ApiCredentials class with isExpired() helper method
src/core/models/CredentialsManagerError.ts Adds comprehensive error code mappings for MRRT operations and extensive JSDoc documentation
src/core/interfaces/ICredentialsManager.ts Extends interface with MRRT methods and detailed documentation
src/core/services/AuthenticationOrchestrator.ts Adds audience parameter to refresh token requests
src/platforms/web/adapters/WebCredentialsManager.ts Implements MRRT for web using @auth0/auth0-spa-js
src/platforms/web/adapters/WebAuth0Client.ts Configures web client with useMrrt option and auto-enables refresh tokens
src/platforms/native/bridge/INativeBridge.ts Adds native bridge interface methods for MRRT
src/platforms/native/bridge/NativeBridgeManager.ts Implements native bridge methods for MRRT operations
src/platforms/native/adapters/NativeCredentialsManager.ts Implements MRRT for native platforms with proper error handling
ios/NativeBridge.swift Adds iOS implementation using Auth0.swift SDK's API credentials methods
ios/A0Auth0.mm Exports native methods to React Native bridge
android/src/main/java/com/auth0/react/A0Auth0Module.kt Implements MRRT for Android with proper parameter conversion and threading
android/src/main/java/com/auth0/react/ApiCredentialsParser.kt Parses Android SDK's APICredentials to React Native format
android/build.gradle Upgrades Auth0 Android SDK to v3.11.0 for MRRT support
src/hooks/Auth0Provider.tsx Adds MRRT methods to React context with proper error handling
src/hooks/Auth0Context.ts Exports MRRT methods in context interface with comprehensive JSDoc
example/src/screens/hooks/CredentialsScreen.tsx Adds example UI for testing MRRT functionality
example/src/screens/class-based/ClassProfile.tsx Updates class-based example to demonstrate MRRT usage
EXAMPLES.md Adds comprehensive MRRT documentation with usage examples for hooks and class-based APIs
FAQ.md Adds trailing commas for code consistency
Tests Adds comprehensive test coverage for MRRT operations across all platforms

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@subhankarmaiti subhankarmaiti merged commit f63fd8c into master Dec 1, 2025
4 checks passed
@subhankarmaiti subhankarmaiti deleted the SDK-6263_mrrt_support branch December 1, 2025 11:31
@subhankarmaiti subhankarmaiti mentioned this pull request Dec 2, 2025
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.

4 participants