-
Notifications
You must be signed in to change notification settings - Fork 267
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
Getting "The request signature we calculated does not match the signature you provided." when creating subscriptions using aws-appsync-subscription-link and apollo client v3 #750
Comments
I can confirm that I am also experiencing the same behavior. My client setup is very similar and looks very close to the readme: import {
ApolloClient,
InMemoryCache,
ApolloLink,
HttpLink,
} from "@apollo/client";
import { createAuthLink, AuthOptions } from "aws-appsync-auth-link";
import { createSubscriptionHandshakeLink } from "aws-appsync-subscription-link";
const createClient = (url: string) => {
const auth = {
type: "AWS_IAM",
credentials: async () => {
return {
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
sessionToken: process.env.AWS_SESSION_TOKEN!,
};
},
} as AuthOptions;
const httpLink = new HttpLink({ uri: url });
const region = process.env.AWS_REGION!;
const config = {
url,
region,
auth,
};
const link = ApolloLink.from([
createAuthLink(config),
createSubscriptionHandshakeLink(config, httpLink),
]);
const apolloClient = new ApolloClient({
link,
cache: new InMemoryCache(),
});
return apolloClient;
};
export { createClient }; I am getting my AWS credentials out of my Lambda function's environment variables. |
@dax-hurley @lyne-jy Did either of you manage to resolve this? We recently migrated off of The query itself is auto-generated through AWS Amplify codegen like all our other queries, so there shouldn't be any syntax errors. |
Ok, so I finally solved my issue, and it was trivial in the end, but the error returned by AWS so very misleading. I'm posting it here as although it's not related to AppSync Subscriptions (I was issuing a Query), if others search for the It turns out my apolloClient.query({
query: gql(myQuery),
variables: {
id: sharedInstanceId,
},
}); And it should have been (as my query's input variable for this query was apolloClient.query({
query: gql(myQuery),
variables: {
sharedInstanceId,
},
}); It was a bug introduced in a refactoring a while back but only caught when switching from Lesson learned. Still that AWS signature error was incredibly misleading, so hopefully this helps someone else out. |
Thanks for the repro @danrivett! Using incorrect top level keys in With a tiny bit of extra logging, it becomes clear that I don't have a quick fix for this, unfortunately. I'll speak with the team internally to decide how best to address this. But, with that understanding of the problem, we at least have something concrete to discuss. And in the meantime, future readers can know what to look for! TLDR; For now, if you see unexpected IAM signing errors, confirm that your requests over the wire match your code, and that your code matches your schema! (And thank-you again for finding a repro, @danrivett!) |
Thanks for investigating this further @svidgen. That's a great explanation of why this happening, that makes sense. It of course would be great to find a solution to this, but until then it's definitely a step forward to understand why it's happening at least. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Recently we upgraded from apollo client v2 to v3 so we also upgraded
aws-appsync-auth-link
andaws-appsync-subscription-link
. When we use apollo client v3 andaws-appsync-subscription-link
to create subscriptions, we get this error:If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
This is how we create the apollo client and the necessary links, basically following the README:
When we use this client to create subscriptions, it returns the error "The request signature we calculated does not match the signature you provided." We can confirm that the credentials are correct. We also have an Amplify client that also uses the same GraphQL API, but that's working fine.
What is the expected behavior?
Return the subscription response without errors.
Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions?
We use:
We've tried apollo client v2 +
aws-appsync-auth-link
v2.x +aws-appsync-subscription-link
v2.x and this combo worked.We tried
aws-appsync
v4.1.9 which also worked.However these are in maintenance mode.
The text was updated successfully, but these errors were encountered: