Jump to content
McKay Development

Recommended Posts

Posted
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?

Posted (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 by Toshima
Posted
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 

Posted (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 by Toshima
Posted
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

 

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...