node-steamcommunity/components/webapi.js
Alexander Corn b82f7ca045 Merge pull request #17 from s992/master
Updates login code to use mobile login headers and cookies
2015-12-02 19:19:50 -05:00

29 lines
627 B
JavaScript

var SteamCommunity = require('../index.js');
SteamCommunity.prototype.getWebApiOauthToken = function(callback) {
var self = this;
if( this.oAuthToken ) {
return callback( null, this.oAuthToken );
}
// Pull an oauth token from the webchat UI
this.request("https://steamcommunity.com/chat", function(err, response, body) {
if(self._checkHttpError(err, response, callback)) {
return;
}
if(self._checkCommunityError(body, callback)) {
return;
}
var match = body.match(/"([0-9a-f]{32})"/);
if (!match) {
callback(new Error("Malformed response"));
return;
}
callback(null, match[1]);
});
};