Closed OliviaB14 closed 5 years ago
Hi. Did you try to wrap the code in an async await?
async function main () {
const { access_token, refresh_token } = await api.getAcceeToken(uuid, tfa);
console.log(access_token, refresh_token);
}
main();
It returns an invalid access token error
{ error: { code: 2105857, message: 'Invalid access token' } } undefined undefined
Ok. Maybe try get a new pair of uuid and 2fa code. There are 3 three steps to get the access token and your uuid and 2fa are consumed and become expired after the first step. You can use the individual api call the monitor all three steps and check what step goes wrong like below.
You have to change the source code and export these three functions BTW.
async function main () {
try {
const { npsso } = await getNpsso(uuid, tfa);
console.log(npsso);
const grantcode = await getGrant(npsso);
console.log(grantcode);
const { access_token, refresh_token } = getToken(grantcode);
console.log(access_token, refresh_token);
} catch(e) {
console.log(e);
}
}
main();
If you required npsso and/or grantcode successfully. They can be used to call the next step instead of requring a new pair of uuid and 2fa code
Your code returns me
undefined null undefined undefined
I did get a new pair of uuid and tfa with this link though : Bungie, so I don't know what I'm doing wrong?
Your code returns me
undefined null undefined undefined
I did get a new pair of uuid and tfa with this link though : Bungie, so I don't know what I'm doing wrong?
Hello I just update the code to use request again and made a more clear readme. Can you try the example again with a new pair of code please? It seems the problem is from node fetch which can't handle redirect page correctly. It used to work fine though.
YES! It finally works thank you :)
One more question : When I retry, the console says error: invalid_ticket
. How can automatically get a new token ?
YES! It finally works thank you :)
One more question : When I retry, the console says
error: invalid_ticket
. How can automatically get a new token ?
Like I said in the previous reply. Your uuid and 2fa code are consumed in the getting token process therefore they can't be use again. I suggest store your refresh token and access token in a getter setter like in the example. Or use fs.write to store them in a file, you could also store them in a database
The access token can barely last about an hour before it expires. and you can use the refresh token to get a new one whenever you like to.
Hi I'm having problems with the access token i think. Here's the error and the code I use Do you have any idea why it doesn't work?
Error message
{ error: 'invalid_request', error_description: 'Mandatory parameter \'code\' is missing', docs: 'https://auth.api.sonyentertainmentnetwork.com/docs/', error_code: 4098 }
Code I used