-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting 400 after login with Npsso: Client does not have grant type sso_cookie #166
Comments
Same here, I thought was a banned IP, but for that case is error 403, not 400, I hope someone can told us something. |
I'm seeing this too and suspect they've disabled the old 2.0 API. EDIT: Done some more testing and the old API endpoints still work so I'm assuming it's just the 2.0 method of authentication that they've disabled? |
Interesting. Thanks. In which version are those old API endpoints? |
Same problem 😞 |
This method works for me. Sorry I can't help with this repo but by PHP skills are long gone and I'm not familiar with this codebase. If you need some more help give me a shout and I'd be more than happy to help. https://github.com/games-directory/api-psn/blob/master/lib/play_station_network_api/session.rb
|
Son of a b..... |
Facing the same issue right now Looking through Network logs on Chrome/Firefox seems that the old 2.0/auth/token endpoint is still used by PSN, but instead of returning the access token and refresh token, its redirected to the new ca.account.sony.com endpoints, which then execute further A comperhensive fix would be much appreciated @pacMakaveli code example is a great starting point, but it seems that it uses some /authz/v3 endpoint which is not being used by the PSN website - is it an endpoint for the app/console? My main concern is how to obtain a refresh token. Getting the access token is easy by just logging in and finding the Bearer, but a refresh token under the current scheme seems either hidden or depreciated |
@kris-dev-cloudwarelab , yes, that endpoint is now used by the new app. |
@pacMakaveli Thank you for the example! But where did you get the |
I don't know about safe, to be honest. After all, the API is not a public resource. I got this by reverse-engineering the PlayStation apk and it's being used by the app. |
@pacMakaveli For those who are still struggling, a few of my learnings from @pacMakaveli code and solution
So these two requests let you go from an npsso you scrape out of your manual login and arrive at a pair of access and refresh tokens which preserve access for 1h for access token and 2 months for the refresh token (which can create new access tokens for you). Or they will both become redundant when PSN does another update.. After a few hours it seems pretty clear, however I would never find those endpoints without the help of @pacMakaveli For those whom this might help, here are the two key pieces of first-draft-code in node.js that works for me. These are written for Node-RED though, so its a bit different, but should illustrate the key points Accessing /authorize
Accessing /token
|
Awesome to hear that! Great job with the detailed description as well. For anyone still struggling, this is my Postman Workspace : https://app.getpostman.com/join-team?invite_code=86c018d31448e533a0ea3f3314f7857b where I test the endpoints. |
Thanks guys -- I'll see if I can update the current version of the library to use the new auth method. I'm still (slowly) working on the new version but I just haven't had much time recently to focus on it. Hopefully I can finish it up soon so we can have the new API all setup when Sony inevitably deprecates the old API. |
Guys, I still didn't figure out how to get the Refresh Token after inputing my NPSSO Token. I tried those examples above using Javascript & Ruby but didn't find a way to make it work. May you give me a example, please? |
I think @kris-dev-cloudwarelab example is very good. Is there an error you get or..? Take us through your process |
@pacMakaveli I sent you an email with a doubt about your Ruby gem, which I'll convert to PHP, but that only worked on Ruby for while (one of the requests). I tried @kris-dev-cloudwarelab 's example in Postman. Once it works I'll convert to PHP, also.. Here's my example using Postman: https://www.getpostman.com/collections/31771518d73338dbafc4 Basically the error is this one: |
You're trying to GET a request. Change the GET to POST and it should work. |
Hello, 403 Forbidden` response: <TITLE>Access Denied</TITLE> Access DeniedYou don't have permission to accessAnyone else same problem? |
403 means your IP is banned for API Requests / Akamai. |
Yes I found it too :( Probably too much request at short time ... I have to use proxy server now, and it works. Hope ban is only temporary. |
hello there, have you finished to convert it into PHP? according to @pacMakaveli 's postman method, I do can get the accesstoken and refreshtoken. However the refreshtoken can not be used in @Tustin 's php lib. I guess the refreshtoken must match the related client-id stuff. It can not be used in the php version lib. |
Any updates on this? |
My app still works fine with the API. If I had to guess, I think @jobsfan is running my method against the old version of the API in this repo. |
Yea... I'm not very good at this, so I'm waiting for an update 😄 EDIT: Also, when i update to dev-master, I get a following error: Uncaught Error: Class 'PlayStation\Client' not found |
Sorry, master branch wasn't quite ready yet so there's a ton of breaking changes that will require you to change some of your code a bit. I wasn't expecting Sony to kill the old API so quickly so I haven't really been focusing on finishing the new API code. |
I've updated the README to show a notice about the current state of the library. I will be working on this during the week to try to get all the bugs ironed out so we can have a working version again 😄 |
@Tustin thank you :) |
Can you please send an updated link for this Postman Workspace? Struggling to learn the new API (just found this repo). EDIT: nevermind, found in another answer, thanks a lot |
I also have this issue since this afternoon. |
You'd get that error if your headers or body are not passed correctly. let axios = require('axios');
let qs = require('qs');
let data = qs.stringify({
'redirect_uri': 'com.playstation.PlayStationApp://redirect',
'scope': 'psn:clientapp psn:mobile.v1',
'token_format': 'jwt'
});
let code = code;
let config = {
method: 'post',
url: `https://ca.account.sony.com/api/authz/v3/oauth/token?code=${ code }&grant_type=authorization_code&redirect_uri=com.playstation.PlayStationApp://redirect`,
headers: {
'Host': 'ca.account.sony.com',
'Referer': 'https://my.playstation.com/',
'Authorization': 'Basic YWM4ZDE2MWEtZDk2Ni00NzI4LWIwZWEtZmZlYzIyZjY5ZWRjOkRFaXhFcVhYQ2RYZHdqMHY=',
'Content-Type': 'application/x-www-form-urlencoded'
},
data : data
};
axios(config).then(function (response) {
console.log(JSON.stringify(response.data));
}).catch(function (error) {
console.log(error);
}); Try this, if it works, it means axios is not sending the headers or body correctly. |
@pacMakaveli same error 🙄
did that work for u tho? |
@pacMakaveli sorry for spamming u 😆 anyways, your XMLHttpRequest example worked, so i'm doing something wrong with axios or it just won't work for this |
ok, so i got it to work with got. just dropping it here, incase anyone curios
|
@pacMakaveli hey, i saw u took down your psn repo. do u still have the api endpoints somewhere? 🙄 |
I sure do! I think pretty much everything is still on postman, but I'll share them here later as well. Sorry, I had to make it private for personal reasons. I hope I can make them public again soon. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@pacMakaveli hello , |
@amirm8170 vlad [at] games [dot] directory |
$psn_client = new Client(); $psn_client->loginWithNpsso('MY TOKEN');
{"error":"unauthorized_client","error_description":"Client does not have grant type: [\"sso_cookie\"]","docs":"https://auth.api.sonyentertainmentnetwork.com/docs/","error_code":4151}
Client error:
POST https://auth.api.sonyentertainmentnetwork.com/2.0/oauth/token` resulted in a400 Bad Request
response: {"error":"unauthorized_client","error_description":"Client does not have grant type: ["sso_cookie"]","docs":"https://a (truncated...)`Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error:
POST https://auth.api.sonyentertainmentnetwork.com/2.0/oauth/token` resulted in a400 Bad Request
response: {"error":"unauthorized_client","error_description":"Client does not have grant type: ["sso_cookie"]","docs":"https://a (truncated...) in C:\xampp\htdocs\psn\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:113 Stack trace: #0 C:\xampp\htdocs\psn\vendor\guzzlehttp\guzzle\src\Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 C:\xampp\htdocs\psn\vendor\guzzlehttp\promises\src\FulfilledPromise.php(41): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 C:\xampp\htdocs\psn\vendor\guzzlehttp\promises\src\TaskQueue.php(48): GuzzleHttp\Promise\FulfilledPromise::GuzzleHttp\Promise{closure}() #3 C:\xampp\htdocs\psn\vendor\guzzlehttp\promises\src\Promise.php(248): GuzzleHttp\Promise\TaskQueue->run(true) #4 C:\xampp\htdocs\ in C:\xampp\htdocs\psn\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 113`The text was updated successfully, but these errors were encountered: