Ich versuche, die verbesserte vereinfachte Authentifizierungsablauf beschrieben auf AWS docsCognito: Wie richtig verbesserte vereinfachte Authentifizierungsablauf implementieren
Problem zu bekommen, ist ich kann nicht herausfinden, wie man richtig das SDK verwenden. ..
AWS.config.region = "ap-northeast-2"
const cognitoParams = {
IdentityPoolId: "ap-northeast-2:...",
Logins: {
"accounts.google.com": googleUser.getAuthResponse().id_token
}
}
AWS.config.credentials = new AWS.CognitoIdentityCredentials(cognitoParams)
const identity = new AWS.CognitoIdentity()
identity.getId(cognitoParams, function (err, identityId) {
console.log(identityId)
const identityParams = Object.assign({}, cognitoParams, {
IdentityId: identityId
})
identity.getCredentialsForIdentity(identityParams, function (err, data) {
console.log(data)
})
})
Das 2 console.log
gibt null
AWS.config.region = "ap-northeast-2"
const cognitoParams = {
IdentityPoolId: "ap-northeast-2:31cc246c-bd2e-46ee-91da-2b8eefcf0745",
Logins: {
"accounts.google.com": googleUser.getAuthResponse().id_token
}
}
AWS.config.credentials = new AWS.CognitoIdentityCredentials(cognitoParams)
AWS.config.credentials.getId(function (err, identityId) {
console.log(identityId)
const identityParams = Object.assign({}, cognitoParams, {
IdentityId: identityId
})
AWS.config.credentials.getCredentialsForIdentity(identityParams, function (err, data) {
console.log(data)
})
})
Das obige gibt mir die Identität aber schlägt mit Cannot read property 'getCredentialsForIdentity' of undefined
fehl.
Wie implementiere ich das?
Was ist "googleUser"? –