amplify-js: Error in Auth.js running the withOAuth example
Describe the bug I’m trying to follow the React Components example, using the withOAuth component (https://aws-amplify.github.io/docs/js/authentication#react-components). The first thing is that I had to change the code to make it compile. I’ve neede to change the class definition to
class App extends Component<{}, { authState: string, authData:any, authError:any }> {
The second thing, is that when I run the example, everything looks like is running correctly but I see the following error in the console:
Auth.js:2202 Uncaught (in promise) TypeError: Cannot read property 'accessToken' of undefined
Taking a look at the code, this is where it fails:
_a = _b.sent(), accessToken = _a.accessToken, idToken = _a.idToken, refreshToken = _a.refreshToken;
because _a is undefined. I guess this can have implications if I then try to make some calls using Amplify.
I’m having this error using a Cognito User Pool and google as authenticator.
To Reproduce Steps to reproduce the behavior: With a react app and a Cognito User Pool configured, configure Amplify using:
const awsmobile = {
"aws_project_region": "eu-west-1",
"aws_cognito_region": "eu-west-1",
"aws_user_pools_id": "<theuserpoolid>",
"aws_user_pools_web_client_id": "<theclientid>",
"oauth": {
"domain": "<yourclient>.auth.eu-west-1.amazoncognito.com",
"scope": [
"email",
"openid"
],
"redirectSignIn": "http://localhost:3000/",
"redirectSignOut": "http://localhost:3000/",
"responseType": "code"
},
"federationTarget": "GOOGLE"
};
Configure Auth using the following object:
const oauth = {
domain: '<yourcognitouserpooldomain>.auth.eu-west-1.amazoncognito.com',
scope: ['email', 'openid'],
redirectSignIn: 'http://localhost:3000/',
redirectSignOut: 'http://localhost:3000/',
responseType: 'token'
};
Expected behavior I expect to see no errors in the console.
Desktop (please complete the following information):
- OS: macOS Mojave, v 10.14.5
- Browser: chrome, v 74.0.3729.169
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 26 (8 by maintainers)
Same error, please reopen.
I’ve a Cognito PreSignup trigger, when i send back a deny with custom message, cognito hosted UI correctly redirects to /myRedirectSignIn?error_description=PreSignUp+failed+with+error+CUSTOM.+&state=v95U7XDI5NKdsLOY7vPfnWPjYK2fVQj0&error=invalid_request
As soon as the page is starting to load, before everything on app side (HUB listners, etc), the error throws up: Unhandled Rejection (TypeError): _a is undefined
This is the console log: