私のiosアプリケーションで他のAWSツールに直接アクセスできるように、次のコードを使用してください。AWS Cognito Identityを使用するポイント
AWSCognitoCredentialsProvider *credentialsProvider = [[DeveloperAuthenticationProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"poolId"];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider];
AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;
__block NSString *cognitoId = nil;
// Retrieve your Amazon Cognito ID
[[credentialsProvider getIdentityId] continueWithBlock:^id(AWSTask *task)
{
if (task.error)
{
NSLog(@"Error: %@", task.error);
}
else
{
// the task result will contain the identity id
cognitoId = task.result;
}
return nil;
}];
次に、AWS LambdaをAPIゲートウェイとともに使用して、ユーザーIDを取得します。
私がこれをコメントアウトしても、私のゲートウェイ機能はまだ機能しています。したがって、s3のようなゲートウェイの外にあるものに直接アクセスしようとすると、失敗するでしょう。右?また、ラムダにアクセスするためにゲートウェイを使用するので、私はhttps://を送ることができます。ありがとう。 – cdub
Cognitoなしでゲートウェイにアクセスできる場合は、世界中の誰もがアクセスできます。あなたは機能が広く開いています。これを使用して、S3からWebにアセットを配信するRESTエンドポイントを提供している可能性があります。それは理にかなっている。 また、iOSのネイティブAWS API呼び出しはすべて、AWS REST APIへのhttps呼び出しに変換されることに注意してください。 –
私はネイティブのhttps:呼び出しを認識しませんでした。 CognitoIdを使用して自分のユーザーだけにAPIを作成するにはどうすればよいですか?ありがとう、 – cdub