Skip to content

Commit 1364458

Browse files
authored
Example doc changes (#796)
2 parents ef6d872 + 9f1e8f6 commit 1364458

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

EXAMPLES.md

+52
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- [Step 2: Input the code](#step-2-input-the-code)
1818
- [Sign Up with a database connection](#sign-up-with-a-database-connection)
1919
- [Get user information](#get-user-information)
20+
- [Custom Token Exchange](#custom-token-exchange)
2021
- [Credentials Manager](#credentials-manager)
2122
- [Secure Credentials Manager](#secure-credentials-manager)
2223
- [Usage](#usage)
@@ -487,6 +488,57 @@ authentication
487488
```
488489
</details>
489490

491+
### Custom Token Exchange
492+
493+
```kotlin
494+
authentication
495+
.customTokenExchange("subject_token_type", "subject_token")
496+
.start(object : Callback<Credentials, AuthenticationException> {
497+
override fun onSuccess(result: Credentials) {
498+
// Handle success
499+
}
500+
501+
override fun onFailure(exception: AuthenticationException) {
502+
// Handle error
503+
}
504+
505+
})
506+
```
507+
<details>
508+
<summary>Using coroutines</summary>
509+
510+
``` kotlin
511+
try {
512+
val credentials = authentication
513+
.tokenExchange("subject_token_type", "subject_token")
514+
.await()
515+
} catch (e: AuthenticationException) {
516+
e.printStacktrace()
517+
}
518+
```
519+
</details>
520+
521+
<details>
522+
<summary>Using Java</summary>
523+
524+
```java
525+
authentication
526+
.customTokenExchange("subject_token_type", "subject_token")
527+
.start(new Callback<Credentials, AuthenticationException>() {
528+
@Override
529+
public void onSuccess(@Nullable Credentials payload) {
530+
// Handle success
531+
}
532+
@Override
533+
public void onFailure(@NonNull AuthenticationException error) {
534+
// Handle error
535+
}
536+
});
537+
```
538+
539+
540+
</details>
541+
490542

491543
## Credentials Manager
492544

0 commit comments

Comments
 (0)