I have an app in React that uses AWS Amplify' API and Auth. I have configured both API_KEY and AMAZON_COGNITO_USER_POOLS for access to the API. I have for example a graphql schema like this:
type Course @model @auth(rules: [
# Defaults to use the "owner" field.
{allow: owner, ownerField: "author", provider: userPools, operations:
[read, create, update, delete]},
# Admin users can access any operation.
{ allow: groups, groups: ["Admin"] },
# Next allow public access with an API Key
{allow: public, provider: apiKey, operations: [read]}
]){
id: ID!
title: String!
content: String!
author: String
}
I have pushed my changes (amplify push) but I get Not Authorized to access createCourse on type Course with a user that has successfully logged in via AWS Cognito when I try to create a course:
API.graphql({
query: createCourse,
variables: {input: {...course}},
authMode: 'AMAZON_COGNITO_USER_POOLS'
})
Extra information:
I am using federated sign-in (Google). A user comes on the site, they signin via Google. The access token is available via: Auth.currentSession()).getIdToken().getJwtToken() but I do not if I have to do anything with this token or it is automatically used in the graphql API call.
{allow: owner, ownerField: "author", provider: userPools, operations: [read, create, update, delete]},- Alex