node package manager
Easy sharing. Manage teams and permissions with one click. Create a free org ยป



Get a Cognito protected text file from an S3 bucket

Continuous Integration Coverage Status Downloads Version License


$ npm init
$ npm install @mitchallen/react-s3-cognito-get-text --save


Here is an example of retrieving a Cognito secured JSON file from S3:

import S3CognitoGetText from '@mitchallen/react-s3-cognito-get-text';

export default async function S3GetJsonFile( params ) {
    return S3CognitoGetText( params )
    .then( data => JSON.parse(data) );

How to call the method above:

import AWS from "aws-sdk";
import authUser from "@mitchallen/react-cognito-auth-user";
const testJsonFile = 'cognito/private/demo.json'

    AWS: AWS,
    authUser: authUser,
    bucket: BUCKET,
    file: testJsonFile, 
    userPoolId: USER_POOL_ID,
    clientId: APP_CLIENT_ID,
    region: REGION, 
    identyPoolId: IDENTITY_POOL_ID
.then((data) => {
.catch(function(err) {

Securing an S3 Bucket for Cognito

For information on how to secure a bucket for Cognito access, see:



In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Version History

Version 0.2.0

  • updated to version of s3 connector that passes AWS to authUser

Version 0.1.0

  • initial release