achievements-app/psn-api

There was a problem retrieving your PSN access code.

c-peiron opened this issue · 5 comments

Hello!

Is this library still working? I find it very interesting but I can't get the token to make the requests.

I get my Npsso, but the exchangeNpssoForCode method always returns the error that gives name to the issue.

Am I missing something?

Thanks in advance

I also can't seem to generate this Code... Can't figure out why.

@c-peiron @juliokugler

No issues here - I am able to generate a code and make requests to the API.

You can verify by downloading the repo and running the playground script:

git clone https://github.com/achievements-app/psn-api.git
cd psn-api
yarn

Get your NPSSO and then open src/__playground.ts.
Set myNpsso to your NPSSO value.

Delete this code:

if (myNpsso === "myNpsso") {
  console.error(
    "⛔️  ERROR: In __playground.ts, modify the myNpsso variable to match your PSN NPSSO.\n"
  );
}

Then run:

yarn playground

You should see a JSON response of your account's user titles.

Curious. I have tried what you say and it works perfectly, however, I copy the same thing in my project, and I get that error. Can it be a matter of testing on localhost?

It can. Are you making calls client-side in a browser? Sony has a CORS policy which causes most modern browsers to conventionally block this. For most of my work with psn-api, I call PSN through a Node.js service, which I then have my clients/apps call. This is an effective circumvention of the issue.

That was just the problem, in a node environment, everything works perfectly. Thank you!