geel9 / SteamAuth

A C# library that provides vital Steam Mobile Authenticator functionality
MIT License
276 stars 102 forks source link

how to generate Steam Guard Code? #86

Closed MKraKoff closed 2 years ago

MKraKoff commented 2 years ago

Hello, i dont undersent the program, how to generate Steam Guard Code by shared secret. So, can you share the finished code with me?

dyc3 commented 2 years ago

You mean this?

https://github.com/geel9/SteamAuth/blob/96ca6af3eb03d1a45f7fbff78851f055ba47c0d4/SteamAuth/SteamGuardAccount.cs#L80-L83

MKraKoff commented 2 years ago

What I should write in program.cs, to get steam guard code? I did it like that, but it didn't work: SteamGuardAccount s1 = new SteamGuardAccount(); s1.SharedSecret = "xxx" s1.GenerateSteamGuardCode()

dyc3 commented 2 years ago

Can you elaborate for me a little more? Post errors. You are missing semi colons in that code, so it won't compile.

MKraKoff commented 2 years ago

image Thats my code, and its working till I will write method a1.GenerateSteamGuardCode(); Is it my code mistake, or not? How can I fix that?

dyc3 commented 2 years ago

No, your code isn't wrong. I think the time API endpoint changed.

POST https://api.steampowered.com/ITwoFactorService/QueryTime/v0001 Response:

{
    "response": {
        "server_time": "1639772146",
        "skew_tolerance_seconds": "60",
        "large_time_jink": "86400",
        "probe_frequency_seconds": 3600,
        "adjusted_time_probe_frequency_seconds": 300,
        "hint_probe_frequency_seconds": 60,
        "sync_timeout": 60,
        "try_again_seconds": 900,
        "max_attempts": 3
    }
}

Something is going wrong with deserialization. I don't remember if newtonsoft json auto converts strings to numbers or not.

MKraKoff commented 2 years ago

Oh my God, how not attentive I am! It turns out that the Newtonsoft library was not installed in this project, although it did not throw any errors. Now the code works, thanks a lot to dyc3 for his help! If someone still does not understand the program, then use this code (xXx= is your secret shared code, you need to insert the full value that is written in ""): image