Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewvanbeek-okta/28faab2b66258617fcea9894fbac0574 to your computer and use it in GitHub Desktop.
Save andrewvanbeek-okta/28faab2b66258617fcea9894fbac0574 to your computer and use it in GitHub Desktop.
Feel Good Server Backend
Backend Api Call
exports.getFeelGoodUsers = (req, res) => {
const OktaJwtVerifier = require('@okta/jwt-verifier');
console.log(req.query.token)
const oktaJwtVerifier = new OktaJwtVerifier({
issuer: '{YOU OKTA ORG URL}/oauth2/default'
})
var accessTokenString = req.query.token
oktaJwtVerifier.verifyAccessToken(accessTokenString)
.then(jwt => {
// the token is valid
console.log(jwt.claims);
const okta = require('@okta/okta-sdk-nodejs');
const client = new okta.Client({
orgUrl: '{YOU OKTA ORG URL}',
token: {Your API TOKEN}, // Obtained from Developer Dashboard
requestExecutor: new okta.DefaultRequestExecutor() // Will be added by default in 2.0
});
var i = 0
var users = []
var request = require("request");
var options = { method: 'GET',
url: '{YOU OKTA ORG URL}/api/v1/users',
headers:
{ 'Postman-Token': 'f633acd0-1fcb-18cc-66d1-52c3e752105e',
'Cache-Control': 'no-cache',
Authorization: 'SSWS {Your API TOKEN}',
'Content-Type': 'application/json',
Accept: 'application/json' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
var userData = JSON.parse(body)
res.status(200).send({"users": userData});
});
let message = req.query.message || req.body.message || 'Hello World!';
})
.catch(err => {
res.status(500).send(err);
});
};
_______________________________
Package JSON
{
"name": "sample-http",
"version": "0.0.1",
"dependencies": {
"@okta/okta-sdk-nodejs": "^1.2.0",
"@okta/jwt-verifier": "0.0.12",
"request": "2.88.0"
}
}
_______________________________
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment