Closed Amogh-G-K closed 2 years ago
Does your Lambda have access to the Access Token JWT for the user or group you would like to authenticate the request with? If so, you should be able to pass that along in the header of each request.
Something along the lines of:
const accessToken = // retrieve from event or context
API.graphql({query: listOrders, authMode: 'custom'}, {'Authorization': accessToken})
I tried this by including the const API = require("@aws-amplify/api");
as to call the GraphQL API but I was not successful doing so as it said API.graphql is not a function
. How to call the API in the Lambda as we can't call it using the HTTPS method mentioned here because it uses IAM and defeats the whole point ?
Hi @Amogh-G-K sorry for the delay. Are you still in need of assistance?
One thing I notice in the code snippet you shared is that you might need to use a named import like this instead
const { API } = require("@aws-amplify/api");
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!
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels or Discussions for those types of questions.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication, GraphQL API
Amplify Categories
auth, api
Environment information
Describe the bug
I have defined GraphQL object in schema.graphql like the following:
But to get the data for the same I have to use a Lambda function ( to call another Third-party API ) and we are using Cognito as authentication. I referred the amplify documentation to call the GraphQL API in the lambda itself. But there were only 2 methods
Expected behavior
To be able to call the GraphQL API in the lambda function using Cognito Userpool as the authentication type.
Reproduction steps
Code Snippet
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