You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having problems when trying to execute the request that gets the code value that is used to obtain the token to connect to the PlayStation API. I've tried everything and I can't understand what it could be. Where I tested the correct value of the SSO token, it reaches the function, but when it tries to communicate with Sony's servers to get the value, it only works on the first attempt in the app on my cell phone. From the second attempt onwards, the request stops working and returns the status code 200, the expected code was 302. I can only make the request return 302 again by clearing the app cache in my cell phone's settings. So I imagine that somehow React Native or Expo may be storing some value or section that is interfering with the requests.
const queryString = new URLSearchParams({
access_type: "offline",
client_id: "09515159-7237-4370-9b40-3806e67c0891",
redirect_uri: "com.scee.psxandroid.scecompcall://redirect",
response_type: "code",
scope: "psn:mobile.v2.core psn:clientapp"
}).toString();
const requestUrl = `https://ca.account.sony.com/api/authz/v3/oauth/authorize?${queryString}`;
const response = await fetch(requestUrl, {
headers: {
'Cookie': `npsso=${npssoToken}`
},
redirect: "manual"
});
const responseHeaders = response.headers;
if (!responseHeaders.has("location") || !responseHeaders.get("location")?.includes("?code=")) {
throw new Error(`
There was a problem retrieving your PSN access code. Is your NPSSO code valid?
To get a new NPSSO code, visit https://ca.account.sony.com/api/v1/ssocookie.
`);
}
// Captura o código de autorização da URL de redirecionamento
const redirectLocation = responseHeaders.get("location") as string;
const redirectParams = new URLSearchParams(redirectLocation.split("redirect/")[1]);
return redirectParams.get("code") as string;
}
I've also tested the exact same code being executed on my PC in isolation in TypeScript and JavaScript, and both methods worked using Axio and Fetch. However, the problem only occurs in my React Native app. I haven't found anything about it on the internet and I can't find another solution.
I tried to debug the code, I already know that the SSO value is correct and valid, if the SSO is invalid then obviously it will return an error and status code 200, but something happens only from the second request onwards that even receiving the correct value, the request always returns 200 and not 302
I have also tried to leave a fixed value for the valid token and the result is the same, on the first attempt it works, on the second attempt the error starts
The text was updated successfully, but these errors were encountered:
I'm having problems when trying to execute the request that gets the code value that is used to obtain the token to connect to the PlayStation API. I've tried everything and I can't understand what it could be. Where I tested the correct value of the SSO token, it reaches the function, but when it tries to communicate with Sony's servers to get the value, it only works on the first attempt in the app on my cell phone. From the second attempt onwards, the request stops working and returns the status code 200, the expected code was 302. I can only make the request return 302 again by clearing the app cache in my cell phone's settings. So I imagine that somehow React Native or Expo may be storing some value or section that is interfering with the requests.
async exchangeNpssoForCode(npssoToken: string): Promise {
console.log("Token NPSSO atual:", npssoToken);
I've also tested the exact same code being executed on my PC in isolation in TypeScript and JavaScript, and both methods worked using Axio and Fetch. However, the problem only occurs in my React Native app. I haven't found anything about it on the internet and I can't find another solution.
I tried to debug the code, I already know that the SSO value is correct and valid, if the SSO is invalid then obviously it will return an error and status code 200, but something happens only from the second request onwards that even receiving the correct value, the request always returns 200 and not 302
I have also tried to leave a fixed value for the valid token and the result is the same, on the first attempt it works, on the second attempt the error starts
The text was updated successfully, but these errors were encountered: