Closed ArjunSohur closed 1 year ago
Hello, @ArjunSohur 👋. Thanks for creating this issue and hoping we can get you unblocked! From what I see in the details you provided, the only error you're seeing is the, "Not Authorized to access createUser on type Mutation". Is this correct?
Can you check the network activity and verify if you see the auth token? If you see it there, we'll likely need to see the schema that you're using if you can share that.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
GraphQL API
Amplify Categories
auth, api
Environment information
Describe the bug
m trying to set up a web app using react.js hosted by amplify on AWS, which I will need to store user preferences of certain categories in a dynamoDB table.
Users must authenticate with Cognito before being able to view/interact with their preferences. I have been having a hard time trying to connect to DynamoDB table that came from the graphQL api which was created with the amplify. In particular, I have been receiving the following error:
Error: Request failed with status code 401 at createError Currently, I try to authenticate the api through "AMAZON_COGNITO_USER_POOLS", however, I have also tried authenticating through IAM, as the answer to this question suggested (Appsync return 401 errors when connecting with cognito).
I have also tried to add more permissions (graphQL and appsync authorization, along with the expected dynampDB permissions) to the identity pool which is the identity provider for the user group which defines the Cognito user pool.
This web app is my first, so it is entirely possible that I'm missing something obvious. Also, my please correct me if my jargon is incorrect or confusing.
I'm more than happy to provide more code if necessary.
Thanks for your help!
Expected behavior
I'd want the information that I send to dynamoDB to be stored.
Reproduction steps
(src looks like:
)
Code Snippet
preferences.js:
App.js:
Log output
aws-exports.js
const awsmobile = { "aws_project_region": "us-east-2", "aws_cognito_identity_pool_id": "us-east-2:", "aws_cognito_region": "us-east-2", "aws_user_poolsid": "us-east-2", "aws_user_pools_web_client_id": "", "oauth": {}, "aws_cognito_username_attributes": [ "EMAIL" ], "aws_cognito_social_providers": [], "aws_cognito_signup_attributes": [ "EMAIL" ], "aws_cognito_mfa_configuration": "OFF", "aws_cognito_mfa_types": [ "SMS" ], "aws_cognito_password_protection_settings": { "passwordPolicyMinLength": 8, "passwordPolicyCharacters": [] }, "aws_cognito_verification_mechanisms": [ "EMAIL" ], "aws_appsync_graphqlEndpoint": "https://jappsync-api.us-east-2.amazonaws.com/graphql", "aws_appsync_region": "us-east-2", "aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS" };