From 52ee65d9daed9bf3ce4b7027dbd7bd0c062b3152 Mon Sep 17 00:00:00 2001 From: Alexander Corn Date: Sat, 26 Dec 2015 18:15:09 -0500 Subject: [PATCH] Added oAuthLogin --- index.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/index.js b/index.js index de0ece4..fc22307 100644 --- a/index.js +++ b/index.js @@ -165,6 +165,39 @@ SteamCommunity.prototype.login = function(details, callback) { } }; +SteamCommunity.prototype.oAuthLogin = function(steamID, token, callback) { + if(typeof steamID !== 'object') { + steamID = new SteamID(steamID); + } + + var self = this; + this.request.post({ + "uri": "https://api.steampowered.com/IMobileAuthService/GetWGToken/v1/", + "form": { + "access_token": token + }, + "json": true + }, function(err, response, body) { + if(self._checkHttpError(err, response, callback)) { + return; + } + + if(!body.response || !body.response.token || !body.response.token_secure) { + callback(new Error("Malformed response")); + return; + } + + var cookies = [ + 'steamLogin=' + steamID.getSteamID64() + '||' + body.response.token, + 'steamLoginSecure=' + steamID.getSteamID64() + '||' + body.response.token_secure, + 'sessionid=' + self.getSessionID() + ]; + + self.setCookies(cookies); + callback(null, self.getSessionID(), cookies); + }); +}; + SteamCommunity.prototype.setCookies = function(cookies) { var self = this; cookies.forEach(function(cookie) {