Jump to content
McKay Development

Trying to Use oAuthLogin


timetoshine

Recommended Posts

My project is very simple. All I want to do is change my profile name by running a script. The name is hard coded, the account is hard coded.

I'm trying to log in without having to provide the two factor code each time I want to run this script. My final goal is to be able to run this script with a push of a button.

 

I was able to get it working with this:

const SteamCommunity = require('steamcommunity')
const Community = new SteamCommunity()

Community.login(
    {
        "accountName": "",
        "password": "",
        "authCode": "",
        "disableMobile": false
    }, (err, sessionID, steamguard, oAuthToken) => {
        Community.editProfile(
            {
                name: "anything"
            },
            (err) => {
                console.log("anything", err)
            }
        )
    }
)

obviously filling out the correct info for my account. Without having steam guard, I was able to change the name no problem. However I want steam guard enabled for obvious reasons but every time I want to run this code, I don't want to input the new authCode.

I can't figure out how to get oAuthLogin(steamguard, oAuthToken, callback) working. The steamguard parameter is confusing to me because the documentation says it's this "YourSteamID||YourCookieValue" but when I get the return it's an array so I can't just pass what I get into oAuthLogin and when I tried to make it a string, I just recreated the oAuthToken thinking I was combining the right info. 

My last run ended up with a 401 error and I'm just completely lost. This is also my first time working with node.

image.thumb.png.332d4bc4b1301ecbd07fa4f927bb5bfb.png

Any advice on what to try or direction of where I should be looking?

 

Solution: 

 

Edited by timetoshine
solution posted
Link to comment
Share on other sites

4 hours ago, Dr. McKay said:

The arguments passed to the login callback are err, sessionID, cookies, steamguard, oAuthToken. You've left out the cookies argument, which is why you aren't getting the correct value in steamguard.

I'm so dumb. Thanks! That was it. I was able to get it working with an email authentication code. I'm now stuck on a mobile code account. When trying to use the steamguard param on login, I get back "Error: SteamGuardMobile"

 

Community.login(
    {
        "accountName": CONFIG.accountName,
        "password": CONFIG.password,
        "steamguard":CONFIG.steamguard,
        //"authCode": "", // email code
        //"twoFactorCode": "", // app code
        "disableMobile": false
    }
    , (err, sessionID, cookies, steamguard, oAuthToken) => {
        if(err) console.log("failed to login: ", err)
        console.log(steamguard)
        console.log(oAuthToken)
    }
)

it works when I put the two factor code in but I'm trying to not have to reenter a code every time I run it.

image.thumb.png.9b425f329f4a75d1e40b449a6c579a33.png

Edited by timetoshine
Link to comment
Share on other sites

I have solved this. I used the oAuthLogin. Originally I thought it was out of the question because the regular login worked for the email two factor code. I just tried oAuthLogin with my steamguard and oauth token and it worked with no issues.

Code that works:

Community.oAuthLogin(CONFIG.steamguard, CONFIG.oAuthToken, err => {
     Community.editProfile(
        {
            name: CONFIGNAME.name
        },
        (err) => {
            if(err) console.log("failed to change name: ", err)
        }
    )
})

 

Link to comment
Share on other sites

  • 1 year later...

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