XenorPLxx / playnite-library-psn

Playnite library extension for PSN.
MIT License
14 stars 3 forks source link

Failed to Import Games from Playstation (authentication issues) #5

Closed DRiBay closed 1 year ago

DRiBay commented 1 year ago

I get the following error message suddenly. "Failed to Import Games from Playstation. User is not authenticated: Token file does not exist." I'm on playnite 10.3. When I try to authenticate it says, "A connection to the server could not be established." I've tried several times over the past week. I'm removed and reinstalled the plugin. Is this something I can fix with a workaround or did it break with an update?

XenorPLxx commented 1 year ago

Hi!

Some users had issues with authentication lately, so let's start with some basic checks:

Playnite should restart after that, and you should be able to try and authenticate again. If it doesn't help, then I'll try to prepare a debug version of the plugin to check what's exactly the problem. You can also upload extensions.log file (it's in menu → About Playnite → 'Other' tab → User data directory), maybe I'll find something there that'll shine more light on this issue.

DRiBay commented 1 year ago

I followed the steps above and got the same error. If I follow the above link it advances to the 2 step verification but in playnite it does not get to that step. There was no token.json file to be deleted which seems to be the error that playnite is showing "token file does not exist." I'm about 90% sure that after uninstalling and reinstalling there was a token file before but one has not generated since. But in both cases I still could not authenticate. Thanks.
extensions.log

Dorennor commented 1 year ago

Same issue, your advices don't work.

XenorPLxx commented 1 year ago

I'm a bit time constrained at the moment, but I'll try to look into it as soon as I'm free.

Dorennor commented 1 year ago

I'm a bit time constrained at the moment, but I'll try to look into it as soon as I'm free.

extensions.log

Dorennor commented 1 year ago

I'm a bit time constrained at the moment, but I'll try to look into it as soon as I'm free.

It's a new log after I was able to login to PSN but extension now get another error.

extensions.log

image image

XenorPLxx commented 1 year ago

@DRiBay here are the steps that @Dorennor discovered to fix it, I'm still unable to reproduce the error in my setup:

I've tried to login, got same error, press "Trouble with login?", press arrow button (previous page) and maximized window(I don't think that it matters but I want to deal all my actions) and in this window I've tried login one more time and it worked for me.

Then Dorennor got an error visible on the screenshots above, but after restart, the plugin magically started working. You can try the same to see if it works.

DRiBay commented 1 year ago

@DRiBay here are the steps that @Dorennor discovered to fix it, I'm still unable to reproduce the error in my setup:

I've tried to login, got same error, press "Trouble with login?", press arrow button (previous page) and maximized window(I don't think that it matters but I want to deal all my actions) and in this window I've tried login one more time and it worked for me.

Then Dorennor got an error visible on the screenshots above, but after restart, the plugin magically started working. You can try the same to see if it works.

Initially this still did not work for me. Looking at the screenshots from Dorennor above though I noticed that I had "Try to migrate games from the old plugin on the next library update" checked. I unchecked that and tried again and logged in fine without doing anything different. So now I can login as well but using a different method than Dorennor.

Dorennor commented 1 year ago

One more logout but now I could login without problems.

image

extensions.log

playnite.log

ceccarelli commented 1 year ago

Same problem here, getting the "A connection to the server could not be established." error, but the url isn't working in the browser as well in my case. Just redirect to the main Playstation Store Page.

perroboc commented 1 year ago

I can confirm this works! Thanks!

cladiesse commented 1 year ago

I have the smae issue : "A connection to the server could not be established." I tried the 2 solutions : clear token and cache ; click on "Trouble with login". Unfortunately none of them worked.

solo-nko commented 1 year ago

Hi!

Some users had issues with authentication lately, so let's start with some basic checks:

Playnite should restart after that, and you should be able to try and authenticate again. If it doesn't help, then I'll try to prepare a debug version of the plugin to check what's exactly the problem. You can also upload extensions.log file (it's in menu → About Playnite → 'Other' tab → User data directory), maybe I'll find something there that'll shine more light on this issue.

Just checking in to say that this worked for me, as well. If I were to guess, the issue was potentially created by the way Playnite's library backup (Library > Backup Library Data) works. I used it this past week when reinstalling Windows; after restoring the data, I found I could no longer log into PSN, encountering this error.

Clearing the token and web cache has seemingly fixed the issue, at least for now.

finkleroy commented 1 year ago

I keep getting the following error: "Failed to import games from PlayStation. Unexpected character encountered while parsing value: <. Path ", line 0, position 0." I'm authenticated. If I logout and login again, I have to click the "are you having trouble logging in" link, then the back button, at which point I can properly login. I've tried everything mentioned here, including deleting token.json and then clearing web cache.

XenorPLxx commented 1 year ago

@finkleroy separate issue, got fixed in #6

finkleroy commented 1 year ago

@finkleroy separate issue, got fixed in #6

Thanks. Sorry for posting it in the wrong place.

BloodShed-Oni commented 1 year ago

Hi!

Some users had issues with authentication lately, so let's start with some basic checks:

Playnite should restart after that, and you should be able to try and authenticate again. If it doesn't help, then I'll try to prepare a debug version of the plugin to check what's exactly the problem. You can also upload extensions.log file (it's in menu → About Playnite → 'Other' tab → User data directory), maybe I'll find something there that'll shine more light on this issue.

Sadly, that didn't work for me.

I can login on the link in my browser, but when I try from Playnite I get this. image

thiagom123 commented 1 year ago

Hi!

Some users had issues with authentication lately, so let's start with some basic checks:

Playnite should restart after that, and you should be able to try and authenticate again. If it doesn't help, then I'll try to prepare a debug version of the plugin to check what's exactly the problem. You can also upload extensions.log file (it's in menu → About Playnite → 'Other' tab → User data directory), maybe I'll find something there that'll shine more light on this issue.

I tried this solution and it didn't work for me as well. After I restarted I got to the capcha screen, but after that it just showed me the same error.

Doaln commented 1 year ago

Just to emphasize for visibility, the workaround that has been successful for others and me is the one Dorennor listed. Click the TROUBLE SIGNING IN? at the bottom, then click the ARROW to the left of Sony to go back to the login screen. Attached photo to illustrate exactly which arrow. troublearrow

jojofofo36 commented 1 year ago

Just to emphasize for visibility, the workaround that has been successful for others and me is the one Dorennor listed. Click the TROUBLE SIGNING IN? at the bottom, then click the ARROW to the left of Sony to go back to the login screen. Attached photo to illustrate exactly which arrow. troublearrow

worked for me !

BloodShed-Oni commented 1 year ago

Just to emphasize for visibility, the workaround that has been successful for others and me is the one Dorennor listed. Click the TROUBLE SIGNING IN? at the bottom, then click the ARROW to the left of Sony to go back to the login screen. Attached photo to illustrate exactly which arrow. troublearrow

Funny enough, when I tried to login again (wanting it to error out again before clicking Trouble signing in?) it working as it should.

MostDefiantly commented 1 year ago

I am also running into the same, and apparently this has been an issue off and on for GOG and other plugin/browser extensions that hit the Sony site for various tasks.

Here's a link on what appears to be the problem: https://github.com/FriendsOfGalaxy/galaxy-integration-psn/issues/7#issuecomment-644759063

And a workaround from the GOG PSN plugin, which I can't find a facsimile in the Token.JSON this plugin uses: https://github.com/FriendsOfGalaxy/galaxy-integration-psn/issues/7#issuecomment-645286024

TL;DR from the various threads I have been reading about the GOG plugin:

"They say it's due to the embedded browser in Galaxy being old, which leads to a "CORS error".

The reason it works sometimes is because if you luck out and get a direct connection to a PSN server, PSN's servers don't care about this issue and will let your request through.

If your request goes to Akamai's load balanacer before PSN, Akamai's filters will throw the CORS error and reject your request."

XenorPLxx commented 1 year ago

@MostDefiantly thanks for the info.

Unfortunately, I was even able to cause that error on a clean Chrome 107 going through the main PlayStation website and manually clicking 'Sign in'.

At this point, it seems like it's out of my hands and Sony has something set up incorrectly.

TO RESOLVE THE ISSUE, follow the steps described here: https://github.com/XenorPLxx/playnite-library-psn/issues/5#issuecomment-1288236965. Sometimes it takes a few tries, but eventually goes through.

zxshima commented 1 year ago

workaround helped, but when i successfully log-in to Playstation website, it automatically refreshes and logs me off a second before closing the window and saying "Requires authentification" again in Configure Integrations window. is there any fix for this? edit: seems like it's country-wide issue (Russia). unfortunate

accodev commented 1 year ago

The workaround doesn't work for me. I noticed, when logging in from sony's website, a captcha is shown, maybe tha captcha is expected and somehow the login throws an error if it misses it?

XenorPLxx commented 1 year ago

@Shevraar @hksy46 a new version of the plugin has been released, available here https://github.com/XenorPLxx/playnite-library-psn/releases/tag/2.17 or in Playnite directly. The new version includes a new authentication method that goes around the problem.

Thanks, @MostDefiantly, for pointing me to the right direction.

Skylin3r commented 1 year ago

for ppl still having issues with this. npsso didn't authenticate for me, kept going back to requires auth. legacy gave server errors what worked for me, I put in the npsso key, hit save, opened the settings again, then click authenticate on the bottom by the legacy method and it worked.

perroboc commented 1 year ago

I'm getting mixed messages. Updating the library shows me this: image

Then I go to the addon settings and see this, instead: image

If I clear the text on the input field, and check again, I get a "requires authentication" message, as expected, but then I use THE SAME token as before, and I get this: image

Then I went into my browser to log out but the thing is I wasn't logged in! image

Seems like https://ca.account.sony.com/api/v1/ssocookie tells me I'm logged in, but not active? Then I clicked "sign in" and I didn't even need to input my credentials, because as you can guess, the cookie was authenticated: image

The token didn't change, as I was already logged in.

So now I manually closed my playstation session to get a new token, and the token URI gives me this message saying I don't have a cookie:

{"error":"invalid_grant","error_description":"Invalid login","error_code":20,"docs":"https://auth.api.sonyentertainmentnetwork.com/docs/","parameters":[]}

Then I continued to input my credentials, OTP, puzzle, and "save these credentials" checked. Now I get a new token... image

It seems to work, now to update the library... image image

So now I think "Ok, the new method doesn't work, I'll try the legacy one". I click on the "Authenticate" button but the window just disappears.

Then I check again if deleting the token from the field works, and... image

So now I really don't know what else to do :|

WingedAsarath commented 1 year ago

I tried the new authentication method yesterday, it worked just fine. When I booted everything up today, it gave me the error that it needed to reauthenticate, but when I went to follow the steps and log back in via the site on my browser, I was given a capture and then told Sony had locked my account and I need to change my password. Seems something about the new method was triggering a flag to lock the account.

nero81af commented 1 year ago

The new method isn't working for me neither the legacy method works.. I'm using chrome as default browser but tried also firefox.. I try to log from europe. I can put the npsso code but still isn't logging in

finkleroy commented 1 year ago

The new method worked fine for me up until now, but it no longer works as of today. After I authenticate, it says, "Requires authentication".

jedcooper commented 1 year ago

Same phenomenom here the Cookie Auth works ONCE for me every cookie change, had that 2-3 times yet. After that - no cookie change, but can't authenticate by cookie anymore - I'm only able to manually login by the legacy method.

finkleroy commented 1 year ago

The plugin now longer works for me at all using both the cookie method and the legacy method. I've tried all the tricks; clearing cache and clicking "trouble signing in?" and then the back arrow and entering my password again. Nothing works.

XenorPLxx commented 1 year ago

@WingedAsarath yea ive had my account locked once too, but didn't happen again, and i've re-logged many times during testing

@nero81af @finkleroy @jedcooper - something changed relating to mobile APIs, try version 2.19 - should work now.

jedcooper commented 1 year ago

@nero81af @finkleroy @jedcooper - something changed relating to mobile APIs, try version 2.19 - should work now.

Confirmed, I'm authenticated by cookie. At least for now :D

michaelsfutter commented 1 year ago

No joy with version 2.20. Same thing. Log in, input NPSSO, "Requires Authentication" loop. Legacy doesn't work either.

BaumherA commented 1 year ago

Was just on the GoG Galaxy thread for this, posting here in case it helps. Generally speaking, the approach of logging in on the user's browser of choice then copying the NPSSO manually works, but its cumbersome. I've seen other applications implement OAuth requests by opening the user's browser of choice and logging in there, then returning to the application with the authenticated results. I haven't fully read up on the PlayNite API (i have read the source code on this repo), but assuming it has the same integrated browser issue as GoG Galaxy, implementing this method would circumvent Akamai's nonsense. The only flaw i can see is the user would remain logged in on their browser; the integrated browsers have their own cookies and do not have this issue. Of course, this would be the case when they log in manually, but it's more obvious when you do it on your own that you should log out if desired.

XenorPLxx commented 1 year ago

@BaumherA I don't believe I can just 'grab a cookie' from an external browser. I would be very unhappy, as a browser user, if that would be possible for a 3rd party app. You've probably seen apps redirecting back from a browser with a prompt that 'this page wants to open this app', but that's something that both sides have to code in (application and the website). This might be possible with some custom browser extension, but that'd be a lot of work for a small improvement. Can you show any examples of OAuth requests opening the user's browser of choice?

BaumherA commented 1 year ago

Python's request library allows you to read cookies, though i think this is via a Get/Post request and their response. IIRC you can send cookies with a Post request, and any response can return cookies along with its regular data. This would of course require server-side code, so you are correct. Sony's API already does this, however, as it exposes the NPSSO cookie as plaintext JSON via (https://ca.account.sony.com/api/v1/ssocookie). You can do a simple Get request on that URL and parse the response as JSON. It will be a Key/Value pair or Tuple (if successful), or empty/an error (if not).

As for the OAuth, an example of doing that externally can be seen at https://stackoverflow.com/questions/36719540/how-can-i-get-an-oauth2-access-token-using-python. However, we (GoG currently, your legacy method) don't really do true OAuth - we don't provide any client ids or secrets, and we also don't ask for a response. Even if we wanted to, Sony's API isn't documented so i don't think we could. Instead, we provide a URL to go to on success and failure. I believe we could take advantage of that success URL to redirect back to the app. Simply have a webpage that has javascript that does a get request on Sony's NPSSO Cookie API, then redirect back to the app with the response. Admittedly, i do not know how to redirect back to the app as of writing this. Perhaps along a port on the localhost?

I'm wondering if we could bundle that webpage with the extension, and store/run it locally. This may require running a localhost as a web server, which i have done before using python, but i don't know how resource intensive that would get.

Also worth noting, PlayNite uses C#, and i have not looked for any equivalent Nuget Packages to do the same as the python libraries. All things considered i much prefer C# but am originally coming at this from GoG so i've been looking at python instead.

BaumherA commented 1 year ago

Here's Google's API Documentation for OAuth from desktop. https://developers.google.com/identity/protocols/oauth2/native-app . I'm going to see if i can get a demo working in C# of an app that can communicate Sony's login stuff, albeit without any of the PlayNite integration. I'll get back to you in a bit. If you would prefer, i can use Telgram/Discord/Skype/Slack (etc) to bounce code ideas.

BaumherA commented 1 year ago

Well, this is a lot rougher than i was expecting. Afaik, the post success url is ignored, so that option is out. I suppose you could try getting Sony to allow you access to their API so we could use the Redirect URI (which is how Google does it), but as it stands, most sites are blacklisted from that, so we can't use it either. another option i tried was to put the login page in an iframe, then detect when the page changes via OnLoad, but content security policy prevents that (it runs on a whitelist). if i can poke at their API long enough, i might find a way to go to a desired site on successful login, at which point all i'd need is a few lines of Javascript and be good to go. Google's sample documentation provides a really simple impementation via httplistener that you can send the npsso back to the application with.

XenorPLxx commented 1 year ago

Yea, I kinda expected that and have chosen to pick my wins and not really invest even more time into trying to figure that out, but if you find a viable solution I'd be happy to help implement that back into PSN library plugin.

TyrantTarnation commented 2 months ago

In order for me to get this working, I ended up logging into PlayStation on Chrome and going to my profile and logging into the security section. Then, I went to playnite and click the link to go to the ssocookie page and the code popped up; this page usually would show an error instead of the code. I added the code and saved. Then updated the PSN library and it worked!

Nio03 commented 1 month ago

So...no working solution in 2024. I tried the deleting cache, but it didn't work

XenorPLxx commented 1 month ago

@Nio03 look up this post https://github.com/XenorPLxx/playnite-library-psn/issues/22#issuecomment-2227230237 For me, using private/incognito browser works.

Also, I know what year it is, no need to remind that.

KZeni commented 3 weeks ago

Side note, if https://ca.account.sony.com/api/v1/ssocookie gives you an error message of "HTTP Status 429 – Too Many Requests" instead of outputting the response details directly as text (this was happening across multiple web browsers for me):

Dunno how widespread this "HTTP Status 429 - Too Many Requests" issue is where the built-in instructions might warrant being updated to point people to using this (I think it could be more consistent in getting people their npsso value so it might just help avoid a potential pitfall, but it is a bit more involved than using the npsso if it happens to be output directly via that webpage if others happen still get that.)

XenorPLxx commented 3 weeks ago

I'll try to write down some notes myself here https://github.com/XenorPLxx/playnite-library-psn?tab=readme-ov-file#http-status-429--too-many-requests, for now I've linked to this comment if you don't mind.

Putting all the notes inside the plugin might make the window too big, linking it to this section should work.