AWS奇才,Google+的验证在AWS Cognito和API网关是未经授权的
我创建了一个POC Web应用程序来测试AWS Cognito
和Federated Identities
一个项目。
我Google+ authentication
延长了POC。当用户通过Google进行身份验证时,Google Signin的计数器在联合身份识别中越来越多,他们显然正在验证。
现在我想用一个固定AWS API Gateway
终点,没有运气使用的凭据。根据网关,用户将保持未知状态。我已经尝试了API网关授权人配置中的测试功能,如果我使用Cognito用户CognitoUserSession.idToken
进行测试,则测试返回声明。
如果我做同样的试验与谷歌用户的idToken
它是未经认证。成功Google签署相同的AWS Javascript SDK代码后(作为Cognito用户登录)。凭证用身份标识和会话标记更新,但没有标识令牌。
正如我在AWS上我可能失去了一些东西,总小白。我应该怎么做才能获得有效的idToken?应该以不同的方式完成吗?
(GoogleLogin是一个阵营成分)
render() {
return (
<GoogleLogin
clientId="44xxx11.apps.googleusercontent.com"
buttonText="Google Login"
onSuccess={this.responseGoogle}
onFailure={this.responseGoogle}
/>
)
}
responseGoogle(response) {
console.log(response.tokenId)
cognitoIdentityCredentials(response.tokenId)
}
cognitoIdentityCredentials(idToken) {
const loginsObj = {
['accounts.google.com']: idToken
}
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: IDENTITY_POOL_ID, // your identity pool id here
Logins: loginsObj
})
AWS.config.credentials.get(function(err) {
if (err) {
console.log(err);
} else {
console.log("---- AWS credentials ----")
console.log(AWS.config.credentials)
// Got credentials, but no valid idToken
}
})
}
代码似乎确定,但没有代码调用LAMBDA ......而这个问题似乎在那里... – UXDart
我为什么要叫LAMBDA在客户端? – Sven
“现在我试图使用带有安全的AWS API网关端点的凭证,但没有运气......” – UXDart