0
我試圖讓AWS docsCognito:如何正確地實現增強簡化認證流程
問題描述的增強簡化認證流程,我可以不知道如何正確使用SDK。 ..
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)
})
})
的2 console.log
給出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)
})
})
上面給我的身份但失敗Cannot read property 'getCredentialsForIdentity' of undefined
。
我該如何實施?
googleUser是什麼? –