federatedInfo from cache is null
See original GitHub issueDescribe the bug
In my React application, I use Google SignIn with AWS Cognito exactly as shown here.
First up: THANK YOU VERY MUCH for the awesome documentation - super helpful and clearly one of the reasons why AWS in general and AWS Amplify especially stand out from the rest! ❤️ 👍 💯
Now, I get valid and plausible credentials using const credentials = await Auth.federatedSignIn(...)
.
However, when I proceed to retrieve a JWT token using const federatedInfo = Cache.getItem('federatedInfo');
, federatedInfo
is always null
.
When I look at Chrome DevTools > Storage > Local Storage, clear the cache and log back in using Google SignIn, I see how an aws-amplify-federatedInfo
key is added with plausible contents, e.g.:
{
expires_at: 159 ... 044
provider: "google"
token: "eyJ ... xxw"
user:
{
id: "us-east-1:f16 ... 2db",
email: "<redacted>",
name: "<redacted>"
}
}
Further, when I list all cache items using Cache.getAllKeys()
, all I get is one unrelated AWSPinpoint_3f38 ... b64
key, although the Chrome Dev Console shows more keys.
What am I doing wrong?
To Reproduce
Run code from official AWS docs referenced above.
Expected behavior
Expected Cache.getItem('federatedInfo');
to return info on the federated user.
Code Snippet
See code in official AWS docs referenced above.
Environment
$ npx envinfo --system --binaries --browsers --npmPackages --npmGlobalPackages
System:
OS: macOS Mojave 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
Memory: 52.19 MB / 16.00 GB
Shell: 5.0.18 - /usr/local/bin/bash
Binaries:
Node: 14.5.0 - /usr/local/bin/node
npm: 6.14.7 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Browsers:
Chrome: 84.0.4147.89
Firefox: 77.0.1
Safari: 13.1.2
npmPackages:
@aws-amplify/core: ^3.4.2 => 3.4.2
@aws-amplify/pubsub: ^3.0.20 => 3.0.20
@sentry/browser: ^5.19.2 => 5.19.2
@storybook/addon-actions: ^5.3.19 => 5.3.19
@storybook/addon-links: ^5.3.19 => 5.3.19
@storybook/addons: ^5.3.19 => 5.3.19
@storybook/preset-create-react-app: ^3.1.4 => 3.1.4
@storybook/react: ^5.3.19 => 5.3.19
aws-amplify: ^3.0.20 => 3.0.20
aws-amplify-react: ^4.1.19 => 4.1.19
bootstrap: ^4.5.0 => 4.5.0
google-auth-library: ^6.0.5 => 6.0.5
react: ^16.13.1 => 16.13.1
react-bootstrap: ^1.2.2 => 1.2.2
react-dom: ^16.13.1 => 16.13.1
react-google-button: ^0.7.1 => 0.7.1
react-redux: ^7.2.0 => 7.2.0
react-router-dom: ^5.2.0 => 5.2.0
react-scripts: ^3.4.1 => 3.4.1
redux: ^4.0.5 => 4.0.5
uuid: ^8.2.0 => 8.2.0
npmGlobalPackages:
npm-check-updates: 7.0.2
npm: 6.14.7
ttab: 0.6.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Update
As a workaround, I am able to obtain the federated info I need as described here:
I don’t know where
localstorage
comes from, might be some builtin React or browser thing; I don’t care, this gets me what I need.This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server
*-help
channels or Discussions for those types of questions.