Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

84
Views
¿Cómo realizar la búsqueda de autorización con la solicitud POST de GraphQL?

Estoy tratando de hacer una solicitud de GraphQL usando el método de búsqueda para obtener un esquema. En AWSAppSync en mi configuración, veo la URL de la API y el ID de la API, pero no tengo idea de cómo configurar mi solicitud POST de recuperación correctamente para obtener la respuesta con los datos que necesito.

Aquí está el código que estoy tratando de usar:

 fetch('https://qnwb7jaoxdyky6egh4.appsync-api.us-east-1.amazonaws.com/graphql', { method: 'POST', headers: { Authorization: 'Basic bnwak7alhw52rlioy', <----- this is API ID from AWS AppSync settings 'Content-Type': 'application/json' }, body: JSON.stringify({ variables: {}, query: ` { __schema { types { kind name possibleTypes { name } } } } `, }), }) .then((result) => result.json()) .then((result) => { debugger; <--------- here I'm expecting to see the response data, but I see an error "UnauthorizedException" // here we're filtering out any type information unrelated to unions or interfaces const filteredData = result.data.__schema.types.filter( (type) => type.possibleTypes !== null, ); result.data.__schema.types = filteredData; fs.writeFile('./fragmentTypes.json', JSON.stringify(result.data), (err) => { if (err) { console.error('Error writing fragmentTypes file', err); } else { console.log('Fragment types successfully extracted!'); } }); });

Estoy usando la URL de la API y el ID de la API de la configuración de AWS AppSync.

No sé por qué, pero aparece un error: "mensaje: "No se puede analizar el token JWT".

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

He pasado la clave API en encabezados como este, en mi caso, estoy llamando al punto final de APPSync Graphql que funciona con la clave API

 headers: { "x-api-key": "XXXX-XXXXXXX", // API key here },
about 4 years ago · Juan Pablo Isaza Report

0

Debe pasar los encabezados correctos en su solicitud POST de AppSync. Los encabezados necesarios varían según el modo de autorización . API Key auth es el "modo de autorización predeterminado" predeterminado. Verifique la pestaña de configuración de la consola de AppSync.

 // API_KEY headers: { `x-api-key`: "da2-the.api.key.from.the.appsync.console" } // AMAZON COGNITO_USER_POOLS headers: { Authorization: "ey.jwt.token.a.really.really.long.string.you.get.from.cognito.after.you.login", host: 'qnwb7jaoxdyky6egh4.appsync-api.us-east-1.amazonaws.com' // the middle bits of the URL }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!