Skip to content

Commit 7821d4b

Browse files
committed
Updated the Exmaples.md file
1 parent 91a2d1a commit 7821d4b

File tree

1 file changed

+78
-2
lines changed

1 file changed

+78
-2
lines changed

EXAMPLES.md

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,10 +738,10 @@ authentication
738738
> [!NOTE]
739739
> This feature is currently available in [Early Access](https://auth0.com/docs/troubleshoot/product-lifecycle/product-release-stages#early-access). Please reach out to Auth0 support to get it enabled for your tenant.
740740
741-
[DPoP](https://www.rfc-editor.org/rfc/rfc9449.html) (Demonstrating Proof of Posession) is an application-level mechanism for sender-constraining OAuth 2.0 access and refresh tokens by proving that the app is in possession of a certain private key. You can enable it by calling the `useDPoP()` method. This ensures that DPoP proofs are generated for requests made through the AuthenticationAPI client.
741+
[DPoP](https://www.rfc-editor.org/rfc/rfc9449.html) (Demonstrating Proof of Possession) is an application-level mechanism for sender-constraining OAuth 2.0 access and refresh tokens by proving that the app is in possession of a certain private key. You can enable it by calling the `useDPoP(context: Context)` method. This ensures that DPoP proofs are generated for requests made through the AuthenticationAPI client.
742742

743743
```kotlin
744-
val client = AuthenticationAPIClient(account).useDPoP()
744+
val client = AuthenticationAPIClient(account).useDPoP(context)
745745
```
746746

747747
[!IMPORTANT]
@@ -785,6 +785,17 @@ DPoP.clearKeyPair()
785785

786786
```
787787

788+
To use DPoP with `SecureCredentialsManager` you need to pass an instance of the `AuthenticationAPIClient` with DPoP enabled to the `SecureCredentialsManager` constructor.
789+
790+
```kotlin
791+
val auth0 = Auth0.getInstance("YOUR_CLIENT_ID", "YOUR_DOMAIN")
792+
val apiClient = AuthenticationAPIClient(auth0).useDPoP(this)
793+
val storage = SharedPreferencesStorage(this)
794+
val manager = SecureCredentialsManager(apiClient, this, auth0, storage)
795+
796+
```
797+
798+
788799
> [!NOTE]
789800
> DPoP is supported only on Android version 6.0 (API level 23) and above. Trying to use DPoP in any older versions will result in an exception.
790801
@@ -1382,6 +1393,28 @@ SecureCredentialsManager manager = new SecureCredentialsManager(this, account, s
13821393
```
13831394
</details>
13841395

1396+
#### Using a Custom AuthenticationAPIClient
1397+
1398+
If you need to configure the `AuthenticationAPIClient` with advanced features (such as DPoP), you can pass your own configured instance to `SecureCredentialsManager`:
1399+
1400+
```kotlin
1401+
val auth0 = Auth0.getInstance("YOUR_CLIENT_ID", "YOUR_DOMAIN")
1402+
val apiClient = AuthenticationAPIClient(auth0).useDPoP(this)
1403+
val storage = SharedPreferencesStorage(this)
1404+
val manager = SecureCredentialsManager(apiClient, this, auth0, storage)
1405+
```
1406+
1407+
<details>
1408+
<summary>Using Java</summary>
1409+
1410+
```java
1411+
Auth0 auth0 = Auth0.getInstance("YOUR_CLIENT_ID", "YOUR_DOMAIN");
1412+
AuthenticationAPIClient apiClient = new AuthenticationAPIClient(auth0).useDPoP(this);
1413+
Storage storage = new SharedPreferencesStorage(this);
1414+
SecureCredentialsManager manager = new SecureCredentialsManager(apiClient, this, auth0, storage);
1415+
```
1416+
</details>
1417+
13851418
#### Requiring Authentication
13861419

13871420
You can require the user authentication to obtain credentials. This will make the manager prompt the user with the device's configured Lock Screen, which they must pass correctly in order to obtain the credentials. **This feature is only available on devices where the user has setup a secured Lock Screen** (PIN, Pattern, Password or Fingerprint).
@@ -1419,6 +1452,49 @@ SecureCredentialsManager secureCredentialsManager = new SecureCredentialsManager
14191452
```
14201453
</details>
14211454

1455+
You can also combine biometric authentication with a custom `AuthenticationAPIClient`:
1456+
1457+
```kotlin
1458+
val auth0 = Auth0.getInstance("YOUR_CLIENT_ID", "YOUR_DOMAIN")
1459+
val apiClient = AuthenticationAPIClient(auth0).useDPoP(this)
1460+
val localAuthenticationOptions =
1461+
LocalAuthenticationOptions.Builder()
1462+
.setTitle("Authenticate")
1463+
.setDescription("Accessing Credentials")
1464+
.setAuthenticationLevel(AuthenticationLevel.STRONG)
1465+
.setNegativeButtonText("Cancel")
1466+
.setDeviceCredentialFallback(true)
1467+
.setPolicy(BiometricPolicy.Session(300))
1468+
.build()
1469+
val storage = SharedPreferencesStorage(this)
1470+
val manager = SecureCredentialsManager(
1471+
apiClient, this, auth0, storage, fragmentActivity,
1472+
localAuthenticationOptions
1473+
)
1474+
```
1475+
1476+
<details>
1477+
<summary>Using Java</summary>
1478+
1479+
```java
1480+
Auth0 auth0 = Auth0.getInstance("YOUR_CLIENT_ID", "YOUR_DOMAIN");
1481+
AuthenticationAPIClient apiClient = new AuthenticationAPIClient(auth0).useDPoP(this);
1482+
LocalAuthenticationOptions localAuthenticationOptions =
1483+
new LocalAuthenticationOptions.Builder()
1484+
.setTitle("Authenticate")
1485+
.setDescription("Accessing Credentials")
1486+
.setAuthenticationLevel(AuthenticationLevel.STRONG)
1487+
.setNegativeButtonText("Cancel")
1488+
.setDeviceCredentialFallback(true)
1489+
.setPolicy(new BiometricPolicy.Session(300))
1490+
.build();
1491+
Storage storage = new SharedPreferencesStorage(this);
1492+
SecureCredentialsManager secureCredentialsManager = new SecureCredentialsManager(
1493+
apiClient, this, auth0, storage, fragmentActivity,
1494+
localAuthenticationOptions);
1495+
```
1496+
</details>
1497+
14221498
**Points to be Noted**:
14231499

14241500
On Android API 29 and below, specifying **DEVICE_CREDENTIAL** alone as the authentication level is not supported.

0 commit comments

Comments
 (0)