Skip to content

Instantly share code, notes, and snippets.

@DavidWells
Created September 3, 2020 06:00
Show Gist options
  • Save DavidWells/051fefee77d6e3f5ec2012e77fecb650 to your computer and use it in GitHub Desktop.
Save DavidWells/051fefee77d6e3f5ec2012e77fecb650 to your computer and use it in GitHub Desktop.
Add cognito auth with amplify without entire framework
// via https://github.com/aws-amplify/amplify-js/discussions/5554
import {Auth} from "@aws-amplify/auth";
....
Auth.configure({
// REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID
identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab',
// REQUIRED - Amazon Cognito Region
region: 'XX-XXXX-X',
// OPTIONAL - Amazon Cognito Federated Identity Pool Region
// Required only if it's different from Amazon Cognito Region
identityPoolRegion: 'XX-XXXX-X',
// OPTIONAL - Amazon Cognito User Pool ID
userPoolId: 'XX-XXXX-X_abcd1234',
// OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string)
userPoolWebClientId: 'a1b2c3d4e5f6g7h8i9j0k1l2m3',
// OPTIONAL - Enforce user authentication prior to accessing AWS resources or not
mandatorySignIn: false,
// OPTIONAL - Configuration for cookie storage
// Note: if the secure flag is set to true, then the cookie transmission requires a secure protocol
cookieStorage: {
// REQUIRED - Cookie domain (only required if cookieStorage is provided)
domain: '.yourdomain.com',
// OPTIONAL - Cookie path
path: '/',
// OPTIONAL - Cookie expiration in days
expires: 365,
// OPTIONAL - Cookie secure flag
// Either true or false, indicating if the cookie transmission requires a secure protocol (https).
secure: true
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment