Skip to content

Commit 1589c8e

Browse files
authored
chore: add docs for metadata support (#8463)
1 parent d8f4f7e commit 1589c8e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/fragments/lib/auth/js/advanced.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,21 @@ These APIs include:
336336
- `confirmResetPassword`
337337
- `resendSignUpCode`
338338
- `updateUserAttributes`
339+
- `fetchAuthSession`
340+
341+
Additionally, you can configure a `ClientMetadataProvider` which passes the `clientMetadata` to internal `fetchAuthSession` calls:
342+
343+
```javascript
344+
// Set global clientMetadata (affects all token refreshes)
345+
import { cognitoUserPoolsTokenProvider } from 'aws-amplify/auth/cognito';
346+
347+
const clientMetadataProvider = () => Promise.resolve({
348+
'app-version': '1.0.0',
349+
'device-type': 'mobile'
350+
});
351+
352+
cognitoUserPoolsTokenProvider.setClientMetadataProvider(clientMetadataProvider);
353+
```
339354
340355
Please note that some of triggers which accept a `validationData` attribute will use `clientMetadata` as the value for `validationData`. Exercise caution with using `clientMetadata` when you are relying on `validationData`.
341356

src/pages/[platform]/build-a-backend/auth/advanced-workflows/index.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,21 @@ These APIs include:
786786
- `confirmResetPassword`
787787
- `resendSignUpCode`
788788
- `updateUserAttributes`
789+
- `fetchAuthSession`
790+
791+
Additionally, you can configure a `ClientMetadataProvider` which passes the `clientMetadata` to internal `fetchAuthSession` calls:
792+
793+
```javascript
794+
// Set global clientMetadata (affects all token refreshes)
795+
import { cognitoUserPoolsTokenProvider } from 'aws-amplify/auth/cognito';
796+
797+
const clientMetadataProvider = () => Promise.resolve({
798+
'app-version': '1.0.0',
799+
'device-type': 'mobile'
800+
});
801+
802+
cognitoUserPoolsTokenProvider.setClientMetadataProvider(clientMetadataProvider);
803+
```
789804
790805
Please note that some of triggers which accept a `validationData` attribute will use `clientMetadata` as the value for `validationData`. Exercise caution with using `clientMetadata` when you are relying on `validationData`.
791806

0 commit comments

Comments
 (0)