achievements-app / psn-api

A JavaScript library that lets you get trophy, user, and game data from the PlayStation Network.
https://psn-api.achievements.app
MIT License
263 stars 31 forks source link

Getting 403 when trying to exchange NPSSO for access code #159

Closed TheMleeOfMlees closed 5 months ago

TheMleeOfMlees commented 5 months ago

Hi, I'm trying to just run the first 3 lines of code to obtain your access token and refresh token, and am receiving a 403 on the call for exchangeNpssoForCode. I followed another example for obtaining it in powershell and that worked fine, so I don't believe it's an issue with the PSN account or NPSSO.

Does anyone have any ideas? I can't find any info on the api documentation in general or why this response is coming. I'm trying to run this from a web application in a browser.

Thank you

wescopeland commented 5 months ago

Hi @TheMleeOfMlees,

This issue is occurring because your browser is throwing a CORS error on the request. Sony has a strict CORS policy which modern browsers will honor. You will likely need to perform your fetches server-side in an API endpoint, than have your client call your API endpoint(s).

TheMleeOfMlees commented 5 months ago

@wescopeland thanks, assumed that was the case but hoped it wasn't. The lack of sony's documentation on their api made this questionable to me. I'm now setting up an express node api that can fetch the data per request, I appreciate your help with this friend, I really appreciate your response.