Closed zachrussell12 closed 1 year ago
After receiving my response from https://www.bungie.net/en/OAuth/Authorize with my code I am attempting to get my token using the following Axios POST request:
const buff = new Buffer.from("<client-id>:<client-secret>", "utf-8"); await axios.post(`https://www.bungie.net/Platform/App/OAuth/Token/?grant_type=authorization_code&client_id=<client-id>&code=${req.originalUrl.split("code=")[1]}`, {}, { headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic ' + buff.toString('base64'), 'X-API-Key': '<my-api-key>', }, }).then((resp)=>{ return res.status(200).json({ message: resp, }); }) .catch(err => { return res.status(500).json({ message: err, }); });
I've looked through almost all of the posts similar to the issue I am having and tried most of the solutions, but to no avail. Here is the specific error code I am getting back for reference:
{ "message": { "message": "Request failed with status code 400", "name": "AxiosError", "stack": "AxiosError: Request failed with status code 400\n at settle (/var/task/node_modules/axios/dist/node/axios.cjs:1855:12)\n at IncomingMessage.handleStreamEnd (/var/task/node_modules/axios/dist/node/axios.cjs:2712:11)\n at IncomingMessage.emit (events.js:412:35)\n at endReadableNT (internal/streams/readable.js:1333:12)\n at processTicksAndRejections (internal/process/task_queues.js:82:21)", "config": { "transitional": { "silentJSONParsing": true, "forcedJSONParsing": true, "clarifyTimeoutError": false }, "adapter": [ "xhr", "http" ], "transformRequest": [ null ], "transformResponse": [ null ], "timeout": 0, "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN", "maxContentLength": -1, "maxBodyLength": -1, "env": { "Blob": null }, "headers": { "Accept": "application/json, text/plain, */*", "Content-Type": "application/x-www-form-urlencoded", "Authorization": "Basic <base64-encoded-string>", "X-API-Key": "<my-api-key>", "User-Agent": "axios/1.2.1", "Accept-Encoding": "gzip, compress, deflate, br" }, "method": "post", "url": "https://www.bungie.net/Platform/App/OAuth/Token/?grant_type=authorization_code&client_id=<client-id>&code=2ad2d3e2ffad30208d92d706c32605ab", "data": "" }, "code": "ERR_BAD_REQUEST", "status": 400 } }
Some help would be much appreciated! Thank you.
This thread resolved my issues!
After receiving my response from https://www.bungie.net/en/OAuth/Authorize with my code I am attempting to get my token using the following Axios POST request:
I've looked through almost all of the posts similar to the issue I am having and tried most of the solutions, but to no avail. Here is the specific error code I am getting back for reference:
Some help would be much appreciated! Thank you.