RezzziRA Posted August 24, 2022 Report Posted August 24, 2022 Testing new login system with api (at this time old login system works fine) Attached 2 methods from bot class. I think general problem arises on PollAuthSessionStatus. I never got access_token prop with i think JWT for https://login.steampowered.com/jwt/finalizelogin Maybe someone know what i made wrong Some info in code comments async sendRequest(url, body = {}, method = 'GET', headers = {}, fetchOptions = {}){ let createSteamQueryStringBody = (body) => { if(Object.keys(body).length == 0) return `` let newBody = `` for(let key in body){ if(typeof body[key] == 'object') body[key] = JSON.stringify(body[key]) newBody += `${key}=${encodeURIComponent(body[key])}&` } return `?${newBody}`.slice(1, -1) } let requestOptions = { headers: { 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8' } } if(this.proxy && this.proxy.includes('http')){ requestOptions['agent'] = new httpsProxyAgent(this.proxy) } if(method != 'GET') requestOptions.body = createSteamQueryStringBody(body) requestOptions.method = method requestOptions.headers = Object.assign(requestOptions.headers, headers) requestOptions = {...requestOptions, ...fetchOptions} let response = await fetch(url, requestOptions) return response } async setupSessionNew(){ try { //generating and setup default cookies for session let sessionID = generateSessionID() let sessionIDCookie = `sessionid=${sessionID}` let responseCookies = await this.sendRequest('https://steamcommunity.com/login', {}, 'GET', {cookies: `${sessionIDCookie}`}) let cookies = this.getSetCookieHeaderCookies(responseCookies.headers.raw()['set-cookie']) cookies.push(`timezoneOffset=10800,0`) cookies.push(`Steam_Language=english`) cookies.push(`ActListPageSize=100`) //create default headers let headers = {cookie: cookies.join(';'), "referer": "https://steamcommunity.com/"} //getting rsa let responseRSA = await this.sendRequest(`https://api.steampowered.com/IAuthenticationService/GetPasswordRSAPublicKey/v1/?account_name=${this.login}`, {}, 'GET', {cookie: cookies.join(';'), "referer": "https://steamcommunity.com/login"}) let jsonRSA = await responseRSA.json() let key = new RSA() key.setPublic(jsonRSA.response.publickey_mod, jsonRSA.response.publickey_exp) //begin auth session let json = { device_friendly_name: '', encrypted_password: hex2b64(key.encrypt(this.password)), account_name: this.login, encryption_timestamp: jsonRSA.response.timestamp, platform_type: 'WebBrowser' } let responseAuthBegin = await this.sendRequest(`https://api.steampowered.com/IAuthenticationService/BeginAuthSessionViaCredentials/v1/`, json, 'POST', headers) let jsonAuthBegin = await responseAuthBegin.json() //this is default response for begin //jsonAuthBegin { // response: { // client_id: '1668888137126125xxxx', // request_id: 'xxxxxAVTm7NzQF56pk3q5A==', // interval: 5, // allowed_confirmations: [ { confirmation_type: 3 } ], // steamid: '76561199217xxxxxx' // } //} //updating twofa code json = { client_id: jsonAuthBegin.response.client_id, steamid: this.steamID, code: steamTotp.getAuthCode(this.shared), code_type: 'DeviceCode' } let responseSteamGuard = await this.sendRequest(`https://api.steampowered.com/IAuthenticationService/UpdateAuthSessionWithSteamGuardCode/v1`, json, 'POST', headers) let jsonSteamGuard = await responseSteamGuard.json() //this is default response for update (protobuf response - empty) //jsonSteamGuard { response: {} } //poll auth status by ids json = { client_id: jsonAuthBegin.response.client_id, request_id: jsonAuthBegin.response.request_id } setInterval(async () => { let responsePoll = await this.sendRequest(`https://api.steampowered.com/IAuthenticationService/PollAuthSessionStatus/v1/`, json, 'POST', headers) let jsonPoll = await responsePoll.json() //jsonPoll { response: { had_remote_interaction: false } } //sometimes got {new_client_id, new_challenge_url} //never got response with {refresh_token and access_token} }, 5000) } catch (error) { console.log(error) } } Quote
Dr. McKay Posted August 25, 2022 Report Posted August 25, 2022 (edited) I've added initial support for using the new login scheme in the api-login branch: https://github.com/DoctorMcKay/node-steamcommunity/pull/292 But I've done it using protobufs to match how the proper Steam website does it. Where'd you get the values that you're sending? Edited August 25, 2022 by Dr. McKay Quote
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.