![](/img/trans.png)
[英]Authenticating user in AWS Cognito User/Identity Pool with Google as identity provider
[英]creating user using AWS cognito identity
我正在學習使用AWS lambda,dynamodb,cogito sync創建無服務器API服務器。 一切順利,直到我對users
表感到困惑。
所以基本上,我正在嘗試制作twitter克隆API。 因此,作為用戶,我應該可以創建帖子,關注其他用戶等。
注冊和登錄已由Cognito身份成功處理,問題是如何訪問cognito上的Users
數據? 用戶可以具有following
和followers
屬性包含其他用戶ID。
我目前所做的,在我使用認知身份注冊的應用程序上,然后我將再次調用API網關以在dynamodb上創建user
。 因此,基本上有兩個單獨的用戶數據。 我不確定這是否是正確的方法。
我應該在后端而不是在應用程序上調用cognito
嗎? 我應該為此使用單獨的users
表嗎?
ionic
上的示例前端代碼
$scope.signup = function() {
$ionicLoading.show({
template: 'Registering user...'
});
// this is the factory for signing up
awsCognitoIdentityFactory.signUp($scope.user.email, $scope.user.name, $scope.user.email, $scope.user.password,
function(err, result) {
if (err) {
errorHandler(err);
return false;
}
// creating user on the api
User.create($scope.user).then(function(response) {
console.log(response);
});
// store locally
store.set('user', $scope.user);
$ionicLoading.hide();
$scope.$apply();
$scope.user = {}; //clear register form
$state.go('confirmation');
});
return true;
};
聽起來您正在使用Cognito用戶池,在這種情況下,您可以使用GetUser API 。 給定用戶上下文,它將返回針對該用戶存儲的所有屬性。
我無法評論存儲用戶元數據的最佳方法,因為它會根據您的應用程序的具體情況和需求而有很大不同,但是值得一讀Cognito的自定義屬性系統,該系統可讓您針對用戶存儲自定義數據。 這些可以從Cognito控制台配置/添加。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.