Jump to content
McKay Development

Login via refresh token


mxnster
 Share

Recommended Posts

Hi!

I'm getting refreshToken via your new steam-session module (startWithCredentials). After a succesful logon I'm passing the refreshToken as a parameter to steam-user module to logOn method. But I am getting an error: 

C:\Users\Administrator\desktop\test\node_modules\steam-user\components\08-logon.js:133
                                        let err = new Error('This refreshToken is not valid for logging in to the Steam client');
                                                  ^

Error: This refreshToken is not valid for logging in to the Steam client
    at C:\Users\Administrator\desktop\test\node_modules\steam-user\components\08-logon.js:133:16
    at processTicksAndRejections (node:internal/process/task_queues:78:11) {
  tokenAudiences: [ 'web', 'renew', 'derive' ]
}

 

There is getting refreshToken module:

import {EAuthTokenPlatformType, LoginSession} from 'steam-session';
import choseAccount from "../functions/choseAccount.js";
import SteamTotp from "steam-totp";
import {setupSteam} from "./setupSteam.js";

let accountData = choseAccount();
export let steamLoginData;

export async function createSession() {
    let session = new LoginSession(EAuthTokenPlatformType.WebBrowser);

    await session.startWithCredentials({
        accountName: accountData.account_name,
        password: accountData.password,
        steamGuardCode: SteamTotp.getAuthCode(accountData.shared_secret)
    });

    session.on('authenticated', async () => {
        console.log(`Logged into Steam as ${session.accountName}`);
        let webCookies = await session.getWebCookies();

        if (webCookies) {
            steamLoginData = {
                accessToken: session.accessToken,
                refreshToken: session.refreshToken,
                webCookies: webCookies
            }
            await setupSteam(steamLoginData)
        }
    });

    session.on('timeout', () => {
        console.log('This login attempt has timed out.');
    });

    session.on('error', (err) => {
        console.log(`ERROR: This login attempt has failed! ${err.message}`);
    });
}

 

And main part of another module:

import SteamCommunity from 'steamcommunity';
import SteamUser from 'steam-user';
import timeout from "../functions/timeout.js";
import TradeOfferManager from 'steam-tradeoffer-manager';
import {sendMessage} from "../functions/sendMessage.js";
import fs from 'fs';


let client = new SteamUser();
let community = new SteamCommunity();

let manager = new TradeOfferManager({
    'steam': client,
    'community': community,
    "domain": "local.com",
    "language": "en",
    "pollInterval": 20000
});


export async function setupSteam(loginData) {
    client.logOn({"refreshToken": loginData.refreshToken})

    client.on('loggedOn', async function () {
        console.log("Logged into Steam as " + client.steamID.getSteamID64());
        client.setPersona(SteamUser.EPersonaState.Online);
        await launchGame(440)
    })

    client.on('error', async function (err) {
        console.log(err)
    })
}

 

I'm using latest versions of modules:

"steam-user": "^4.25.0",
"steam-session": "^0.0.2-alpha"
Link to comment
Share on other sites

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...
 Share

×
×
  • Create New...