-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rest API Calls with Authenticated Users and User Groups #13785
Comments
Hey, @thomasdavidwang 👋. Can you clarify which docs you were following to set up the group roles and access? Also, does your If you could share the code snippet of how you're calling the API, that may help as well. Thanks! |
Hi @cwomack, thanks for looking into this! The user groups were created according to: https://docs.amplify.aws/react/build-a-backend/auth/concepts/user-groups/ Appropriate users are automatically put into a user group using a post-confirmation trigger: https://docs.amplify.aws/react/build-a-backend/functions/examples/add-user-to-group/ And our backend does attach the relevant policies to the authenticated and unauthenticated roles, as described in the docs you shared. We're calling the API using amplify. This is the relevant code snippet: let restOperation = post({ However, what we were seeing from the API Gateway access logs is that the API calls were being made using a User Group Role, which did not have the appropriate policies, and not the authenticated user role. Also, the API is confirmed to work for unauthenticated users, as well as authenticated users who are not in a user group. |
@thomasdavidwang, thanks for the follow up and additional context. This looks related to another issue in the |
@thomasdavidwang, we're tracking this as a bug on the |
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
REST API
Amplify Version
v6
Amplify Categories
api
Backend
Amplify Gen 2 (Preview)
Environment information
Describe the bug
I created a Rest API using Amplify Gen 2 and AWS CDK according to the documentation, using IAM as an authorizer. When attempting to call this API from the frontend, the API calls were being made with the Group Role instead of the Authenticated User Role. As a result, we were getting 403 errors that stated "The client is not authorized to perform this operation."
Expected behavior
Successful API Requests
Reproduction steps
Code Snippet
// Put your code below this line.
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: