Toshima Posted April 5 Report Share Posted April 5 (edited) Is there a way to retrieve accessToken using tradeoffer-manager? Edited April 5 by Toshima Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted April 6 Report Share Posted April 6 No, use steam-session for that. Quote Link to comment Share on other sites More sharing options...
TheMaster Posted April 7 Report Share Posted April 7 On 4/5/2024 at 7:08 PM, Toshima said: Is there a way to retrieve accessToken using tradeoffer-manager? acutally u can listed to client.on wesbsession as it has the callback cookies u and the steam login secre cookie u can extract the access token from there ill give u the function to do that function extractJWTToken(tokenString) { const jwtRegex = /ey[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_.+/=]+/; const jwtToken = tokenString.match(jwtRegex); return jwtToken ? jwtToken[0] : null; } client.on('webSession', async (sessionID, cookies) => { //console.log(cookies) let jwtToken = extractJWTToken(cookies[0]) //console.log(jwtToken) cookiesformarket=jwtToken manager.setCookies(cookies, function(err) { //console.log(cookies) if (err) { console.log(red,err); process.exit(1); // Fatal error since we couldn't get our API key return; } safePromise(withTimeout(stayOnline(refreshToken, marketapi,cookiesformarket), 10000,"stayOnline")) // Adjust timeout as needed .catch(error => console.error(red,'Error staying online:', error)); // Error handling //webapi=manager.apiKey //fetchActiveTradeOffers(); // Call the function } ); 21 hours ago, Dr. McKay said: No, use steam-session for that. can u testify my answer? Quote Link to comment Share on other sites More sharing options...
Toshima Posted April 7 Author Report Share Posted April 7 (edited) 23 hours ago, TheMaster said: acutally u can listed to client.on wesbsession as it has the callback cookies u and the steam login secre cookie u can extract the access token from there ill give u the function to do that function extractJWTToken(tokenString) { const jwtRegex = /ey[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_.+/=]+/; const jwtToken = tokenString.match(jwtRegex); return jwtToken ? jwtToken[0] : null; } client.on('webSession', async (sessionID, cookies) => { //console.log(cookies) let jwtToken = extractJWTToken(cookies[0]) //console.log(jwtToken) cookiesformarket=jwtToken manager.setCookies(cookies, function(err) { //console.log(cookies) if (err) { console.log(red,err); process.exit(1); // Fatal error since we couldn't get our API key return; } safePromise(withTimeout(stayOnline(refreshToken, marketapi,cookiesformarket), 10000,"stayOnline")) // Adjust timeout as needed .catch(error => console.error(red,'Error staying online:', error)); // Error handling //webapi=manager.apiKey //fetchActiveTradeOffers(); // Call the function } ); can u testify my answer? thanks, it's work well, but definitely the same as using steam-session Edited April 7 by Toshima Quote Link to comment Share on other sites More sharing options...
TheMaster Posted April 8 Report Share Posted April 8 2 hours ago, Toshima said: thanks, it's work well, but definitely the same as using steam-session NP, and definitely your choice this function and method automatically updates the access token when ever the websession is established and the plus point is that u dont need to write another function to me its more compact Quote Link to comment Share on other sites More sharing options...
Toshima Posted April 8 Author Report Share Posted April 8 (edited) 19 hours ago, TheMaster said: NP, and definitely your choice this function and method automatically updates the access token when ever the websession is established and the plus point is that u dont need to write another function to me its more compact u talk about "StayOnline" method? it's looks like your own method. I would be grateful if you share it, cuz event "sessionExpired" in tradeoffer-manager not working as i expected. I don’t quite understand how the "sessionExpired" event is triggered, because at some point incoming exchanges stop being processed and the "newOffer" event does not fire and the session expired event also does not fire anything...still testing Edited April 8 by Toshima Quote Link to comment Share on other sites More sharing options...
TheMaster Posted April 11 Report Share Posted April 11 On 4/9/2024 at 1:14 AM, Toshima said: u talk about "StayOnline" method? it's looks like your own method. I would be grateful if you share it, cuz event "sessionExpired" in tradeoffer-manager not working as i expected. I don’t quite understand how the "sessionExpired" event is triggered, because at some point incoming exchanges stop being processed and the "newOffer" event does not fire and the session expired event also does not fire anything...still testing well that seems like a bigger problem with your connection logic the session websession even is called when ever ur current websession expires its a automatic process and does not require ur intervention u need to look at ur reconnection or the weblogon etc stuff i think Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.