Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Grants packageId to steamId provided publisher web api key via nodejs endpoint
const fetch = require('node-fetch')
const FormData = require('form-data')
export default function(req, res) {
const payload = new FormData()
payload.append('key', 'publisher_steam_web_api_key')
payload.append('steamid', 'user_steam_id')
payload.append('packageid', 'package_id')
payload.append('ipaddress', '0.0.0.0')
fetch('https://partner.steam-api.com/ISteamUser/GrantPackage/v1/', {
method: 'POST',
body: payload,
headers: payload.getHeaders(),
})
.then(res => res.json())
.then(json => {
console.log('STEAM GrantPackage Success', json)
req.logout()
console.log('Session Logged Out')
res.status(200).send('steam package granted!')
})
.catch(err => {
console.log('STEAM GrantPackage Error')
console.error(err.toString())
res.status(400).json({message: 'steam granting error occured'})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment