Amplify API subscription failing authorization

0

I have a React application that currently uses Amplify GraphQL APIs. I have set those APIs up so that they require using Cognito user pools for authorization. For example the following code is successfully retrieving a list of values from my Projects collection in DynamoDB

const apiData = await API.graphql({ query: listProjects, authMode: "AMAZON_COGNITO_USER_POOLS"  });

Recently I have been trying to setup a subscription so that I can receive real time updates from AppSync when new entries are added to my Projects collection. This is the code that I am trying to get to work:

const subscription = API.graphql({query: subscriptions.onUpdateProject, authMode: "AMAZON_COGNITO_USER_POOLS"}
    ).subscribe({
    next: ({ provider, value }) => console.log({ provider, value }),
    error: error => console.warn(error)
});

Unfortunately, this code is failing when executed, it is causing this error to be raised:

"Connection failed: {\"errors\":[{\"errorType\":\"Unauthorized\",\"message\":\"Not Authorized to access onUpdateProject on type Project\"}]}"

I am not quite sure how to troubleshoot this or resolve it, do subscriptions require a special configuration with respect to authorization? Are Cognito user pools supported with subscriptions? Any help or guidance would be greatly appreciated.

질문됨 2년 전90회 조회
답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인