aws-samples / aws-samples/amazon-sumerian-hosts
How to refresh credentials for Polly?
- Dominant language
- JavaScript
- Stars
- 210
- Forks
- 83
- PR merge metrics
- No merged PRs in 30d
Description
We're using aws-amplify for authentication. There's a helpful API called Auth.currentCredentials() which will return valid credentials generated by the attached identity pool.
I have this effect sitting in my root component:
```
/**
* refresh the AWS credentials
*/
useEffect( () => {
const THIRTY_MINUTES_MS = 1800000;
setInterval( async () => {
const [creds] = await Promise.all([Auth.currentCredentials()]);
const { accessKeyId, secretAccessKey, sessionToken } = creds;
AWS.config.credentials = new AWS.Credentials({
accessKeyId,
secretAccessKey,
sessionToken
})
}, THIRTY_MINUTES_MS);
}, []);
```
Even with this code, it appears that credentials are expiring after an hour. How can I refresh the AWS credentials for this library?
Thanks.
Contributor guide
Assessment
This issue has not been assessed yet.