Cognito Authorization

Required to have:

  • User Pool Region (example: eu-central-1)
  • User Pool ID (example: eu_central_111111)
  • User Pool Web Client ID (example: 1234qwerty7890asdfg)
  • UsernameID (example: e7c6ae40-ca66-4d2a-8d37-337d3e8c92bb) - is required to generate username (uuid v5) based on UsernameID and email. Ask LabelRails team for access.

(User Pool Region, User Pool ID, User Pool Web Client ID - will be provided by LabelRails tech team)

Install AWS Amplify and connect Auth API according to the documentation: Amplify Auth API.

You can either use a custom UI by connecting Auth API: Custom UI or Amplify Authenticator Component: Authenticator Component.

API Usage

Required to have:

  • API host URL (will be provided by LabelRails tech team).

If you want to use AWS Amplify to fetch data, which we recommend, then follow this documentation: REST API with AWS Amplify.

You can also use any other tool to fetch data. To use authorization via Cognito User Pool, you must retrieve the user idToken and send it in headers.

import { fetchAuthSession } from 'aws-amplify/auth'

const session = await fetchAuthSession();
const token = session.tokens?.idToken;
const headers = { Authorization: token };