Created
January 22, 2019 05:46
-
-
Save andrewvanbeek-okta/eb4ed448a6f58900c5130bebd937ee3e to your computer and use it in GitHub Desktop.
Feel Good Update HealthData
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.sendHealthData = (req, res) => { | |
console.log("#*Y#*Y&#&*#&#T&&#^^&#&#&*#") | |
console.log(req.query) | |
console.log("#*Y#*Y&#&*#&#T&&#^^&#&#&*#") | |
const okta = require('@okta/okta-sdk-nodejs'); | |
const client = new okta.Client({ | |
orgUrl: '{YOUR OKTA ORG URL}', | |
token: '{YOUR OKTA API TOKEN}', // Obtained from Developer Dashboard | |
requestExecutor: new okta.DefaultRequestExecutor() // Will be added by default in 2.0 | |
}); | |
var userId = req.query.userId | |
var healthData = req.query | |
client.getUser(userId) | |
.then(user => { | |
console.log(user) | |
if(healthData.type == "consumed") { | |
user.profile.consumedCalories = healthData.hValue | |
} else if(healthData.type == "burned") { | |
user.profile.burnedCalories = healthData.hValue | |
} else if(healthData.type == "sleep") { | |
user.profile.sleepHours = healthData.hValue | |
} | |
user.update().then(() => res.status(200).send({"message": "user updated"})); | |
}); | |
}; | |
________________________________________________ | |
Package JSON | |
{ | |
"name": "sample-http", | |
"version": "0.0.1", | |
"dependencies": { | |
"@okta/okta-sdk-nodejs": "^1.2.0" | |
} | |
} | |
________________________________________________ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment