jhewt / gumer-psn Goto Github PK
View Code? Open in Web Editor NEWA Playstation Network API written in Node.js
License: MIT License
A Playstation Network API written in Node.js
License: MIT License
Looking to build a simple PSN friends list menubar app with notifications and such myself. Nice work so far!
Starting gPSN
gPSN | Getting login
express deprecated router.param(fn): Refactor to use path params node_modules/express/lib/application.js:331:16
gumerPSN Example running at http://localhost:3000/
gPSN | Logging in, sending POST
gPSN | Logged in, following redirects
/Users/michael/Dev/gumer-psn/psn.js:132
getAccessToken(codeResult[1])
^
TypeError: Cannot read property '1' of null
at Request._callback (/Users/michael/Dev/gumer-psn/psn.js:132:30)
at Request.self.callback (/Users/michael/Dev/gumer-psn/node_modules/request/request.js:198:22)
at Request.emit (events.js:110:17)
at Request.<anonymous> (/Users/michael/Dev/gumer-psn/node_modules/request/request.js:1073:14)
at Request.emit (events.js:129:20)
at IncomingMessage.<anonymous> (/Users/michael/Dev/gumer-psn/node_modules/request/request.js:1019:12)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
I started sniffing the traffic from the app so I can help out. The duid that I have is different than the one you have. Did you find that this is different across devices too? I'm still looking for the client_secret to see if it's any different from what you posted as well.
Hey, Unfortunately every once a while oauth token (client_id, client_secret, ...) gets expired and causes your code to not work anymore
Does anybody know a way to get a new "client_id" and "client_secret" with "grant_type=password" permission ?
Callback not passed to getAccessToken
in followRedirect
I was planning on using this to add functionality for an app I'm working on currently, but after going through the code, I noticed your clientId is hardcoded within the psn.js file.
I imagine this is something that would come with access to the API from Sony. I just wanted to ask if there is a way to acquire a client Id directly from sony, or if while using the code, I would have to use your clientId.
Just trying to avoid any potential issues from Sony
How many of you are running the lastest Node.js, or better yet, io.js?
I want to rewrite the module in ECMAScript 6 mantaining the same API.
First of all, thank you for this great project.
I'm wondering if there is a way to know about ‘default language’ when requesting the trophy info?
As we know, a trophy set with multi-language will return a fixed (default) language when we request with another language which is not in its supported languages.
For example, the result of a pure Japanese game will have Japanese as its language even if we provide the argument npLanguage = ‘en’
.
I’ve tried set npLanguage = ‘’
or send request without this argument, but I got a server-side error:
"response":
{
"error": {
"code": 2138373,
"message": "'npLanguage' parameter required in query string"
}
}
Since the last privacy changes in PSN it is not working anymore. I don't know if it is just my case or everybody's.
ypeError: Cannot read property '1' of null
at Request._callback (/root/node_modules/gumer-psn/psn.js:132:30)
at Request.self.callback (/root/node_modules/gumer-psn/node_modules/request/request.js:198:22)
at Request.emit (events.js:98:17)
at Request. (/root/node_modules/gumer-psn/node_modules/request/request.js:1035:10)
at Request.emit (events.js:117:20)
at IncomingMessage. (/root/node_modules/gumer-psn/node_modules/request/request.js:962:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:442:13)
[root@ns3009754 gumer-psn]# nano index.js
[root@ns3009754 gumer-psn]# node index.js
Starting gPSN
gPSN | Getting login
gumerPSN Example running at http://localhost:3000/
gPSN | Logging in, sending POST
gPSN | Logged in, following redirects
TypeError: Cannot read property '1' of null
at Request._callback (/root/node_modules/gumer-psn/psn.js:132:30)
at Request.self.callback (/root/node_modules/gumer-psn/node_modules/request/request.js:198:22)
at Request.emit (events.js:98:17)
at Request. (/root/node_modules/gumer-psn/node_modules/request/request.js:1035:10)
at Request.emit (events.js:117:20)
at IncomingMessage. (/root/node_modules/gumer-psn/node_modules/request/request.js:962:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:442:13)
Hello Jose,
I'm running telegram bot, which posts new PSN achievements to channel. Bot is based on your API.
It worked fine for some months. And today your API starts reporting some errors:
gPSN | Asking for new token
gPSN | Getting login
gPSN | Logging in, sending POST
gPSN | Logged in, following redirects
gPSN | ERROR: Error: options.uri is a required argument
and does not answer on requests.
$ npm --version
1.4.23
Thanks for your help.
i wrote a script to test the concurrency, on grabbing psn profiles - since there is no limit doing so on Sony's end.
However, the script just froze when we reached to maybe like 1500?
any reason to this? my server is a beast and should be able to handle it, would be script's fault.
Hello Jose,
I have tried updating since it stopped working because of the PS login changes, although I am back to the same issues as before :(
On the previous update, I had to change the last to lines to get it to work on Heroku to -
app.listen(Number(process.env.PORT || 5000));
console.log('gumerPSN Example running at port: ' + Number(process.env.PORT || 5000));
I am doing the same thing with the latest, and getting Application Error.
Here's a paste of the web.js
http://pastebin.com/pC39uxVL
and here's a log of the push
http://pastebin.com/us6eA2my
any help is much appreciated, thank you!
I'm getting an error attempting to run the example:
gPSN | ERROR: {"error":"invalid_grant","error_description":"Bad request","docs":"http://docs.auth.api.ac.playstation.net/oauth/token","error_code":1}
Hello again.
First time using the /gameID and they all give me the error "report to github"
I have gotten these 2 to display the json
/PSN/your_id
/PSN/your_id/trophies
Although all of the ones below give that error.
/PSN/your_id/trophies/gameID
/PSN/your_id/trophies/gameID/groups
/PSN/your_id/trophies/gameID/groups/groupID
/PSN/your_id/trophies/gameID/tophyID
Due to making a wrong callback, when a new data request is perform and the access_token has expired it does not request a new csrf token.
This is not a bug, but I didn't know where else to ask this:
After successfully logging in and getting the access token, is there a way we can log out / purposefully time out the access token?
Basically Sony wants you to login to the PSN using your credentials and then get a token so you can request info for the next hour at which time you need another token. I have a heroku app on a server that has a front-end login that will check the credentials and return basic PSN profile information of whoever logs in. The web worker of the heroku app only gets activated when someone goes to the heroku app url. After that, the web worker shuts down - but I believe the token gets saved and is active for the next hour. So when the next person tries to check this (or a couple people after that), PSN starts temporarily blocking token access for the heroku app.
Is there a simple logout mechanism we could try? I know there is a logout button on Sony's Auth page: https://auth.api.sonyentertainmentnetwork.com/loginSuccess.jsp. Could we execute this same functionality?
In the community will show the user's country, but I want my friend's country.thanks
Starting gPSN
gPSN | Getting login
gumerPSN Example running at http://localhost:3000/
gPSN | authCode obtained: eula!i
gPSN | Login for the first time
gPSN | ERROR: {"error":"invalid_grant","error_description":"Bad request","docs":"http://docs.auth.api.ac.playstation.net/oauth/token","error_code":1}
I'm getting a socket hangup in the example.
gPSN | Invalid "eu" region value, using "us" instead
gPSN | Getting login
gPSN | Logging in, sending POST
gPSN | Logged in, following redirects
/Users/jasperdansercoer/kayzrapi/node_modules/gumer-psn/psn.js:132
getAccessToken(codeResult[1])
^
TypeError: Cannot read property '1' of null
at Request._callback (/Users/jasperdansercoer/kayzrapi/node_modules/gumer-psn/psn.js:132:30)
at Request.self.callback (/Users/jasperdansercoer/kayzrapi/node_modules/request/request.js:188:22)
at emitTwo (events.js:125:13)
at Request.emit (events.js:213:7)
at Request.<anonymous> (/Users/jasperdansercoer/kayzrapi/node_modules/request/request.js:1171:10)
at emitOne (events.js:115:13)
at Request.emit (events.js:210:7)
at IncomingMessage.<anonymous> (/Users/jasperdansercoer/kayzrapi/node_modules/request/request.js:1091:12)
at Object.onceWrapper (events.js:314:30)
at emitNone (events.js:110:20)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1047:12)
at _combinedTickCallback (internal/process/next_tick.js:102:11)
at process._tickDomainCallback (internal/process/next_tick.js:198:9)
Any idea? Is this related to my incorrect region? Because the docs don't state what the possible regions are.
solved
Thank you for taking the time to create the project and showcase how people can integrate with PSN - fantastic job.
Finding this project was really easy but finding any kind of documentation or hearing from anyone with experience in integrating PSN OAuth has been next to nil. But unfortunately the lack of official documentation or information of any kind (that I can find) worries me.
I have just a couple of questions I'd like to ask about this project and to the people who have integrated it into their own websites:
(1) Are you imitating another server in your requests? That's what it seems to be doing - you are setting a false origin header right? I only assume with any other origin the server just does not respond? What is the legality of imitating another server?
(1-a) A follow-up: Does this break any TOS for the person with the PSN account. Could Sony take action against users who use a 3rd party site or application to access information through their PSN account?
(2) What kind of reliability does this project have? How often do API changes occur that may break a service that implements this code or approach? When an API change occurs is there any notice or does it immediately result in no-service?
(2-a) A follow-up: How are you checking for service outages or deprecation of the API so that you do not show your visitors a "sign-in with PSN" button, for example.
I'm sure I'll have more questions as I continue to explore the possibility of officially integrating PSN / Xbox Live log in to my site.
Thanks,
Gumer-psn is now running pretty good. However, for trophy data, I can not get infomation of trophyDetail and trophyName etc. How can i solve this problem.
After a while I am getting the following response:
{"error":true,"message":"Something went terribly wrong, submit an issue on GitHub please!","response":{"error":{"code":2105867,"message":"Rate limit exceeded"}}}
I know that this error comes from PSN indicating I'm doing too much requests but does anybody know what the amount/time ratio is? or how this could be bypassed?
I've been doing some research regarding getting hidden trophy information. It looks like major trophy sites use the .ESFM file decryption and hash generation method to fill in all trophies for games in conjunction with the PlayStation mobile application/website. I found some sample code on the psdevwiki for downloading trophy related files: http://www.psdevwiki.com/ps3/Trophy_files#Tools
The trick is to find the HMAC key, erk, and iv for running the python script. I haven't been able to locate these just yet, but in theory, one should be able to get these from the metadata header on the np_trophy_util.sprx/prx file from a PS3 firmware extraction. After this is done, files should be able to download. I don't know how to decrypt ESFM files at the moment, but I think that there are tools available that can handle decryption. If anyone has pointers on how to extract the HMAC key, erk, and iv, I think we can make this part of the API to get hidden trophy information. Currently, it appears that larger organizations profit off of the mentioned method and it would be great to open source the method.
According to this PSN API written in Java a DUID is a unique identifier Sony uses to distinguish between devices based on the manufacturer name and the MAC address of the device.
When initiating, it says:
gPSN | Logging in, sending POST
gPSN | Logged in, following redirects
TypeError: Cannot read property '1' of null
at Request._callback (/root/psnapi2/gumer-psn-6fbe8fbf225ed7517154617e58f1770467ce1eee/psn.js:132:30)
at Request.self.callback (/root/psnapi2/gumer-psn-6fbe8fbf225ed7517154617e58f1770467ce1eee/node_modules/request/request.js:198:22)
at Request.emit (events.js:98:17)
at Request. (/root/psnapi2/gumer-psn-6fbe8fbf225ed7517154617e58f1770467ce1eee/node_modules/request/request.js:1073:14)
at Request.emit (events.js:117:20)
at IncomingMessage. (/root/psnapi2/gumer-psn-6fbe8fbf225ed7517154617e58f1770467ce1eee/node_modules/request/request.js:1019:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:448:13)
app.get('/PSN/feed/:id', function(req, res){ gumerPSN.getFeed(req.params.id, function(error, eventFeed) { if (!error) { res.send(eventFeed) } else { if (eventFeed.error.code == 2105356) { // User not found code res.send({ error: true, message: "PSN ID not found" }) } else { res.send({ error: true, message: "Something went terribly wrong, submit an issue on GitHub please!", response: eventFeed }) } } }) })
exports.getFeed = function (psnid, callback) { if (accessToken.length > 1) { debug('Asking profile events for: ' + psnid); psnGETRequest(psnURL.eventFeed.replace("{{id}}", psnid),callback); } else { debug('Asking for new token'); getAccessToken('',function() { psnGETRequest(psnURL.eventFeed.replace("{{id}}", psnid),callback); }) } }
,eventFeed: 'https://activity.api.np.km.playstation.net/activity/api/v1/users/{{id}}/feed/0?includeComments=true&includeTaggedItems=true&filters=PURCHASED&filters=RATED&filters=VIDEO_UPLOAD&filters=SCREENSHOT_UPLOAD&filters=PLAYED_GAME&filters=WATCHED_VIDEO&filters=TROPHY&filters=BROADCASTING&filters=LIKED&filters=PROFILE_PIC&filters=FRIENDED&filters=CONTENT_SHARE&filters=IN_GAME_POST&filters=RENTED&filters=SUBSCRIBED&filters=FIRST_PLAYED_GAME&filters=IN_APP_POST&filters=APP_WATCHED_VIDEO&filters=SHARE_PLAYED_GAME&filters=VIDEO_UPLOAD_VERIFIED&filters=SCREENSHOT_UPLOAD_VERIFIED&filters=SHARED_EVENT&filters=JOIN_EVENT&filters=TROPHY_UPLOAD&filters=FOLLOWING&filters=RESHARE'
this never returns any data, any idea why?
I am getting the following error
{"error_code":4151,"error":"unauthorized_client","error_description":"Client does not have grant type: ["implicit","authorization_code"]","docs":"http://central-auth.p1-np-eib.prod.navcloud.sonynei.net/docs/#api/centralauthservice/v1/oauth/authorize/get"}
Where in the android app can I get the client ID and client secret?
Since last Friday July the 3rd the API is not working anymore. It is not able to obtain the access_token due to changes in the login page apparently made by Sony. Does anyone else have this problem?
Hello!
Just wanted to thank you again for working on the code for this. Unfortunately I have no knowledge of running node.js and it appears my hosting account does not allow it on shared hosting. I am going to try and figure out how to run node.js on my localhost, because I really want to see this working.
Question: Is this the same thing you had on your site running?
Because I noticed the file asked for login information. Is that only to login and actually 'view' other peoples trophies etc?
Can you give me any hints or guides on how to get started with node.js?
Thank you!
[root@10-4-5-5 gumer-psn]# node app.js
gPSN | Getting login
gPSN | Asking for new token
gPSN | Login for the first time
gPSN | ERROR: {"error":"4098","error_description":"Mandatory parameter 'code' is missing","docs":"http://docs.auth.api.ac.playstation.net/oauth/token","error_code":4098}
gPSN | authCode obtained: k97y2D
gPSN | Login for the first time
gPSN | access_token/refresh_token obtained: {"access_token":"a1f1678e-c7e2-4890-b506-897bb36d61fd","token_type":"bearer","refresh_token":"ba2fa306-9b07-4baf-b5b0-0b128659ffe5","expires_in":3599,"scope":"psn:sceapp"}
I've found a way to get hidden trophy name and details. It's kinda tricky, but it allows me to show hidden trophies automatically (I have a bot for Telegram, which posts new trophies of my friends to our group). There is a file with all trophies here http://ps3trophies.com/games/all/all , so I just download it and parse (if you need more detailed algorithm, let me know, and I will share it).
I just wanted to say I am looking forward to this project. I have been looking for something that works for a month now, and kept reaching your site after multiple threads and google searches..
I honestly do not know too much about oauth, but am trying to learn. I can handle most php code, and can't wait for a release! I am new to json also, but it seems pretty simple. I noticed on your site http://losgumer.jsachs.net/feta/PSN/ you are generating json files? Or are those pulled from Playstation and can we use them on our own site?
http://losgumer.jsachs.net/feta/PSN/KJthaDon/json/trofeos
I just wanted to thank you ahead of time and appreciate the work!
Is possible to indicate that a given user is online or not?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.