Skip to content

Cognito auth tutorial is faulty #1016

@TeoTN

Description

@TeoTN

The Cognito auth tutorial is faulty and technically it won't work.

The problem is that up until recently (it changed two weeks ago on the 13/12/2023) Cognito didn't support adding custom claims to access token at all (see this announcement). Now it technically does offer the customisation but the feature requires enabling Advanced Security Shenanigans, which are super duper costly, and the tutorial doesn't cover this at all.

So if you checked your tokens post-authentication like this:

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

const session = await fetchAuthSession();
console.log('session', session);

You'll find out that while id token gets updated, the access token doesn't have the claims (unless you're willing to pay up to $2500 for 50k MAU offered by Free Tier Cognito)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions