Skip to content

Instantly share code, notes, and snippets.

@vinnymac
Created September 13, 2022 03:10
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vinnymac/e94d89e2881ef76167440a60b0a067d6 to your computer and use it in GitHub Desktop.
Save vinnymac/e94d89e2881ef76167440a60b0a067d6 to your computer and use it in GitHub Desktop.
Chiaki helper script to determine Account ID from any modern browser

Instructions

  1. Open the browser of your choice
  2. Visit https://playstation.com (and sign out if you are signed in)
  3. Open the developer tools for your browser, and click on the network activity tab
  4. Choose to preserve the network log on the network tab

image

  1. Now sign back into the playstation site
  2. Search the network activity for requests named id, and click on one of them
  3. Find the Request Headers section and look for the Authorization header image
  4. Record the bearer token of the authorization header that matches: Authorization: Bearer [COPY_ALPHANUM_HERE], you will need this in a second
  5. Open a new tab, and navigate to https://web.np.playstation.com/ (it will say 'Access Denied', it's safe to ignore)

image

  1. Open the developer tools, navigate to the console tab, copy & paste the script from here into the console, and hit enter
  2. Enter the bearer token and click OK

image

Congrats, you should see your account id, and if you are using a browser that supports clipboard writes, it will already be in your clipboard.

(async () => {
const bearerToken = window.prompt(
`Enter the Authorization header bearer token here:`
);
function longToByteArray(long) {
let byteArray = [0, 0, 0, 0, 0, 0, 0, 0];
let big = BigInt(long);
for (let index = 0; index < byteArray.length; index++) {
const byte = Number(big & 0xffn);
byteArray[index] = byte;
big = BigInt((big - BigInt(byte)) / 256n);
}
return byteArray;
}
function arrayBufferToBase64(buffer) {
let binary = '';
const bytes = new Uint8Array(buffer);
for (let i = 0; i < bytes.byteLength; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
let base64AccountId;
try {
const res = await fetch(
'https://web.np.playstation.com/api/basicProfile/v1/profile/users/me',
{
credentials: 'include',
headers: {
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:104.0) Gecko/20100101 Firefox/104.0',
Accept: '*/*',
'Accept-Language': 'en-US,en;q=0.5',
Authorization: `Bearer ${bearerToken}`,
'Content-Type': 'application/json; charset=utf-8',
},
}
);
const { accountId } = await res.json();
base64AccountId = arrayBufferToBase64(longToByteArray(accountId));
} catch (err) {
console.error(`Something went wrong... Sorry!`);
console.error(err);
}
try {
await navigator.permissions.query({ name: 'clipboard-write' });
} catch (err) {}
try {
await navigator.clipboard.writeText(base64AccountId);
console.log(`Account ID has been copied to clipboard successfully!`);
} catch (err) {
console.error(err);
}
if (base64AccountId) {
console.log(`Account ID is ${base64AccountId}`);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment