twitchtv / igdb-api-node

Nodejs Wrapper for IGDB.com API. Requires an API key. Get one at:
https://api.igdb.com/
MIT License
128 stars 15 forks source link

Authorization error, the library sends request with using the client secret as bearer token instead of requesting a bearer token #63

Closed GerardPolloRebozado closed 2 months ago

GerardPolloRebozado commented 2 months ago

code:

import { Request, Response } from "express";
import igdb from "igdb-api-node";

const client = igdb(process.env.TWICH_CLIENT_ID, process.env.TWICH_CLIENT_SECRET);

export const getGame = async (req: Request, res: Response) => {
  try {
    const { id } = req.params;
    console.log(client)
    const game = await client.fields(['name', 'cover', 'summary', 'platforms', 'genres', 'release_dates', 'screenshots', 'videos', 'websites']).where(`id = ${id}`).request('/games');
    console.log(game.data);
    res.json(game.data);
  } catch (error) {
    console.log(error);
  }
}

error: data: { message: 'Authorization Failure. Have you tried:', 'Tip 1': 'Ensure you are sending Authorization and Client-ID as headers.', 'Tip 2': "Ensure Authorization value starts with 'Bearer ', including the space", 'Tip 3': 'Ensure Authorization value ends with the App Access Token you generated, NOT your Client Secret.', Docs: 'https://api-docs.igdb.com/#authentication', Discord: 'https://discord.gg/igdb' }

the headers show this: _header: 'POST /v4/games HTTP/1.1\r\n' + 'Accept: application/json\r\n' + 'Content-Type: application/x-www-form-urlencoded\r\n' + 'client-id: my client id' + 'authorization: Bearer my_client_secret' + 'x-user-agent: igdb-api-node v5.0.2\r\n' + 'User-Agent: axios/0.21.4\r\n' + 'Content-Length: 101\r\n' + 'Host: api.igdb.com\r\n' + 'Connection: keep-alive\r\n' + '\r\n',