amplify-js: Error using federated sign-in
Do you want to request a feature or report a bug? Report a bug
What is the current behavior?
I’m trying to use a federated sign-in, but getting an error:
TypeError: Cannot read property 'identityPoolId' of undefined
at Credentials._setCredentialsFromFederation (react-dom.development.js:17306)
at Credentials.set (react-dom.development.js:17306)
at react-dom.development.js:17306
at new Promise (<anonymous>)
at AuthClass.federatedSignIn (react-dom.development.js:17306)
at ProxyComponent._callee$ (_overRest.js:37)
at tryCatch (_iter-define.js:70)
at Generator.invoke [as _invoke] (es6.array.iterator.js:35)
at Generator.prototype.(:1234/anonymous function) [as next] (http://localhost:1234/src.539ec86d.js:4889:21)
at step (_overRest.js:3)
My files: index.tsx
...
import Amplify from 'aws-amplify'
Amplify.configure({
Auth: {
identityPoolId: process.env.AWS_IDENTITY_POOL_ID,
mandatorySignIn: true,
region: process.env.AWS_REGION,
userPoolId: process.env.AWS_USER_POOL_ID,
userPoolWebClientId: process.env.AWS_USER_POOL_CLIENT_ID,
cookieStorage: {
domain: process.env.AWS_COOKIE_DOMAIN
}
}
})
...
GoogleSignIn.tsx
async federatedSignIn(googleUser: gapi.auth2.GoogleUser) {
const { id_token, expires_at } = googleUser.getAuthResponse()
const profile = googleUser.getBasicProfile()
let user = {
email: profile.getEmail(),
name: profile.getName()
}
if (
!Auth ||
typeof Auth.federatedSignIn !== 'function' ||
typeof Auth.currentAuthenticatedUser !== 'function'
) {
throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported')
}
await Auth.federatedSignIn('google', { token: id_token, expires_at }, user) <- error is happening here
user = await Auth.currentAuthenticatedUser()
}
What is the expected behavior? It should sign user in using google token
Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions?
"aws-amplify": "^1.0.2"
MacOS: 10.13.6
Google Chrome: 67.0.3396.99
You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = 'DEBUG'; in your app.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 16 (3 by maintainers)
@powerful23
I am getting this issue.
import API from ‘@aws-amplify/api’; import config from ‘…/…/src/aws-exports’
API.configure(config); …
And I get this error.
API - ensure credentials error TypeError: Cannot read property ‘identityPoolId’ of undefined
For those who still with the problem, I just had to call the configure method from the Amplify lib before using the Auth methods. Like that:
I can’t confirm that this is not working for 1.0.8 for us. Our code looks like this:
The values for
authare all set regarding to the Logger output. When we then call Auth to get the federatedCredentials with this function here:We see the following error:
If we debug and take a look at the Amplify.Auth object, it seems to be empty:
It all works with 1.0.0 but not with any version higher.