cypress-io / cypress-realworld-app

A payment application to demonstrate real-world usage of Cypress testing methods, patterns, and workflows.

Home Page:https://docs.cypress.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Amazon Cognito Authentication v6 unsupported

raverecursion opened this issue · comments

AWS Amplify v6 was released on Nov 15, 2023, with several breaking changes.
The examples on the website and in the repo doesn't work with the new version.

@innellea

If you want to view a preview of the documentation change, with the addition of v6 information, you can find it here. It hasn't been approved yet, however it may help you in the meantime.

commented

I'm very happy to see that you reached out, @innellea . I noticed the same thing and pieced together how to convert to v6, and wanted to contribute back my learnings, which is why I opened cypress-io/cypress-documentation#5610 . Thank you @MikeMcC399 for your response in discord and your pointer here! I would not have found this issue in cypress-realworld-app without it.

commented

Turns out the documentation update was declined, but to anyone finding this page, that closed PR 5610 does have a working example.

@timheilman

Turns out the documentation update was declined, but to anyone finding this page, that closed PR 5610 does have a working example.

Where do you read that the documentation update was declined? I am seeing that you yourself closed the PR
image

I don't see any note that the Cypress.io team declined the documentation update.

commented

Oh, maybe I was confused. I thought that was how a decline was processed: that the PR was assigned to the submitter. I don't have write access to the repo, so I had no way to move the PR forward. The only further action I could take without any comments, review, or approval was to close it, so I figured that's why she assigned it to me.

@timheilman

Oh, maybe I was confused. I thought that was how a decline was processed: that the PR was assigned to the submitter. I don't have write access to the repo, so I had no way to move the PR forward. The only further action I could take without any comments, review, or approval was to close it, so I figured that's why she assigned it to me.

Although I don't understand the logic of assigning a PR to the submitter of the PR, it certainly does not mean that the PR was declined.

I suggest you go back and re-open the PR and then be patient. Your PR is out of necessity quite complex, so reviewing it is more demanding and may take more time.

commented

oh, okay, that was my mistake. I reopened it.

If you're encountering problems with JWT (access and ID tokens) in Amplify, one aspect to verify is whether Amplify is correctly configured to use localStorage as your token storage mechanism.

While the Amplify documentation indicates localStorage as the default, aws-amplify@6.0.27 opted for cookies instead, I spent a few hours debugging this.

import { Amplify, type ResourcesConfig } from 'aws-amplify';
import { defaultStorage } from 'aws-amplify/utils';
import { cognitoUserPoolsTokenProvider } from 'aws-amplify/auth/cognito';

const authConfig: ResourcesConfig['Auth'] = {
  Cognito: {
    userPoolId: 'your_user_pool_id',
    userPoolClientId: 'your_user_pool_client_id'
  }
};

Amplify.configure({
  Auth: authConfig
});

cognitoUserPoolsTokenProvider.setKeyValueStorage(defaultStorage);