-
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
Undocumented breaking change: unauthenticated user can't call GraphQL APIs after upgrading from V5 to V6 #12710
Comments
Same problem here |
Possibly related to #12687 (although that one is REST API). @daudiihhdau, is your AppSync API managed by Amplify? Or do you also have the GraphQL endpoints managed outside of Amplify? |
Yes, I use a CDK stack that uses Appsync to provide an external GraphQL API. |
Ah, nice catch! Thanks for letting us know the cause of the issue, that rules out that this might've been related to the REST API issue, so that's good to know 🙏 |
@chrisbonifacio I opened this issue and I'm glad it's working now for @daudiihhdau but the issue is still unresolved for my app. My app is also React and not Vue as far as issue tagging for triage/support. @daudiihhdau was the missing |
My apologies, @manwaring, I confused who was the OP 😅 Reopened. I'd be curious to see what the request headers and response look like for the failing graphql queries. Can you share those details from the network activity? Or is there not even a request being sent? Just the error being thrown? One other thing that might be worth looking at is the value of |
Hello, here is the crucial code snippet from my Vue3 app.
The missing setup keyword is Vue specific. It starts the Vue3 Composition API. |
Hey guys, I've had a similar problem, had a long call with AWS support. Amplify.configure(
{
Auth: {
Cognito: {
region: process.env.AWS_REGION,
userPoolId: process.env.USER_POOL_ID,
userPoolClientId: process.env.USER_POOL_WEB_ID,
},
},
API: {
GraphQL: {
endpoint: process.env.GRAPH_QL_ENDPOINT,
region: process.env.AWS_REGION,
defaultAuthMode: "userPool",
},
},
},
{
API: {
GraphQL: {
headers: async () => ({
Authorization: (await fetchAuthSession()).tokens?.idToken?.toString(),
}),
},
},
},
); Here also an example GraphQL call: export const listWebsites = async () => {
const result = await client.graphql({
query: gql`
query listWebsites {
listWebsites {
websiteId
name
createdAt
lastModified
}
}
`,
authMode: 'userPool'
});
return result.data.listWebsites;
}; Maybe it helps someone :) |
FWIW anybody who is trying to get unauthenticated identity pool access to use with an external provider if you enable For example, export const config : ResourcesConfig= {
Auth: {
Cognito: {
userPoolId: process.env.NEXT_PUBLIC_COGNITO_USER_POOL_ID!,
userPoolClientId: process.env.NEXT_PUBLIC_COGNITO_CLIENT_ID!,
identityPoolId: process.env.NEXT_PUBLIC_COGNITO_IDENTITY_POOL_ID!,
allowGuestAccess: true,
},
},
} If your Identity Pool is setup correctly const session = await fetchAuthSession()
{
"credentials": {
"accessKeyId": "KEY_ID",
"secretAccessKey": "ACCESS_KEY",
"sessionToken": "TOKEN",
"expiration": "DATETIME"
},
"identityId": "ap-southeast-2:UUID"
} and you can check if this session is defined versus a cognito session with a token. |
I solved this, by upgrading |
Thanks @kochie when making config changes I removed "mandatorySignIn: false" but didn't replace it with "allowGuestAccess: true" |
I am having the exact same issue getting an I read through these comments and adding So my question is; is that the recommended solution or is that a shortcut/hack? |
@mattiLeBlanc from what I know, there were two different issues folks were running into with iam as an auth mode. Historically, enabling unauthenticated access via the Amplify CLI was a step that could be missed by some and is required for the Amplify graphql client to use the UnauthRole and sign requests. This can also now be enabled on the Amplify configuration using the allowGuestAccess field on the Auth.Cognito resource config option and is the recommended approach. There was a separate issue regarding using public iam as an auth mode in SSR apps. This was fixed recently in last week's release (v6.0.17). |
@chrisbonifacio Just for clarity; I am not using any amplify generated stuff, I just use the Auth lib and Graphql API in my own Angular services. I have a cognito pool and an identity pool for IAM users (non auth) that need to do some things like passwordless login or other no authenticated flows. So, is setting allowGuestAccess = true the right move for me? |
I have this query along with this type:
After following the proposed changes/workarounds here and from this closed(why?) issue my unauthenticated user sees the error: "Not Authorized to access url on type SignedUrl" Is it necessary to configure auth rules on simple types? EDIT:
Edit #2: |
Hi @manwaring following up on this issue. It seems the fix has been a bit different for the other users in this thread. I noticed when you opened this issue you were on 6.0.7 and a fix has been released since. Can you try upgrading to the latest version of |
Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you. Thank you! |
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication, GraphQL API
Amplify Categories
Not applicable
Environment information
Describe the bug
While upgrading from V5 > V6 I've found a blocker issue / breaking change that I can't find documentation for and am unable to complete the migration without a fix - either in my setup or in the lib.
Error: No credentials at GraphQLAPIClass._headerBasedAuth
Thank you so much for your help with this issue, and my sincerest apologies if I'm missing a step from the upgrade guide - I've tried multiple times going through it but it feels like this could be a config error.
Expected behavior
Reproduction steps
Code Snippet
CloudFormation GraphQL Authentication configuration
React V5 GraphQL call
React V5 Amplify Configuration
React V6 GraphQL call
React V6 Amplify Configuration
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: