Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save VityaSchel/06754fcbebb8b8fa52b96d0abfdc424b to your computer and use it in GitHub Desktop.
Save VityaSchel/06754fcbebb8b8fa52b96d0abfdc424b to your computer and use it in GitHub Desktop.
Comparison of all PSN API wrappers for JavaScript

I have tested all 4 wrappers for JavaScript

Library name Is archived Last commit Can log in Can return trophies Can read messages First encountered error
PSNjs 2015 ? ? {"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"}
gumer-psn 2021 ? ? {"error":"invalid_request","error_description":"Mandatory parameter 'code' is missing","docs":"https://auth.api.sonyentertainmentnetwork.com/docs/","error_code":4098}
psn-api 2021 {"error":{"referenceId":"4941a051-7bb4-11ec-aa64-971307734cc4","code":2240513,"message":"Bad Request (path: sort)"}}
pxs-psn-api 2020 ? ? unauthorized_client

None of them work and the only one that may work in future is psn-api but it was specifically made for trofies. No python or php compilers to javascript available in our world yet.

My conclusion: it's impossible to make something working with PSN API unless you are really crazy mad man who decided to develop its own wrapper. In this case, please share it to the world or work on psn-api or PSNjs because they are the most promising libraries out there.

import 'dotenv/config'
import gumerPSN from 'gumer-psn'
gumerPSN.init({
debug: true,
email: process.env.PSN_EMAIL,
password: process.env.PSN_PASSWORD,
npLanguage: "en",
region: "us",
})
gumerPSN.getProfile(process.env.PSN_NICKNAME, function(error, profileData) {
console.log(profileData)
})
// import psnApi from 'psn-api'
// const { exchangeNpssoForCode, exchangeCodeForAccessToken, getUserTitles } = psnApi
require('dotenv').config()
const { exchangeNpssoForCode, exchangeCodeForAccessToken, getUserTitles } = require('psn-api')
async function main(){
const accessCode = await exchangeNpssoForCode(process.env.PSN_NPSSO)
const authorization = await exchangeCodeForAccessToken(accessCode)
console.log(authorization.accessToken);
const trophyTitlesResponse = await getUserTitles(
{ accessToken: authorization.accessToken },
process.env.PSN_NICKNAME
)
console.log('trophies', trophyTitlesResponse)
}
main()
import 'dotenv/config'
import PSNjs from 'PSNjs'
const psn = new PSNjs({
email: process.env.PSN_EMAIL,
password: process.env.PSN_PASSWORD,
debug: true,
authfile: ".psnAuth"
});
psn.getUserTrophies((error, data) => {
if (error) {
console.log("Error fetching trophies: " + error);
return
}
console.log(JSON.stringify(data, null, 2));
})
import 'dotenv/config'
import PSN from 'pxs-psn-api'
const api = new PSN
async function getProfile() {
const access_token = await api.auth(process.env.PSN_NPSSO)
console.log(accessToken);
const profile = await api.getProfile(access_token, '4421126145254737307')
return profile
}
getProfile()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment