<commit_before>const express = require("express");
const log4js = require("log4js");
const passport = require("passport");
const APIStrategy = require("./../lib/appid-sdk").APIStrategy;

const app = express();
const logger = log4js.getLogger("testApp");

app.use(passport.initialize());

passport.use(new APIStrategy({
	tenantId: "e9be2ca6-b280-43b9-b3b9-d03809d8390f",
	serverUrl: "https://workingfromhome.stage1.mybluemix.net/imf-authserver"
}));

app.get("/api/protected",
	passport.authenticate(APIStrategy.STRATEGY_NAME, {
		session: false,
		scope: "default" // TODO: Change to appid_default after server side update
	}),
	function(req, res) {
		var appIdAuthContext = req.appIdAuthorizationContext;
		var username = "Anonymous";
		if (appIdAuthContext.identityTokenPayload){
			username = appIdAuthContext.identityTokenPayload.name;
		}
		logger.debug(req.appIdAuthorizationContext);
		res.send("Hello from protected resource " + username);
	}
);

var port = process.env.PORT || 1234;

app.listen(port, function(){<commit_msg>updated sample to return proper scope<commit_after>const express = require("express");
const log4js = require("log4js");
const passport = require("passport");
const APIStrategy = require("./../lib/appid-sdk").APIStrategy;

const app = express();
const logger = log4js.getLogger("testApp");

app.use(passport.initialize());

passport.use(new APIStrategy({
	tenantId: "e9be2ca6-b280-43b9-b3b9-d03809d8390f",
	serverUrl: "https://imf-authserver.stage1.mybluemix.net"
}));

app.get("/api/protected",
	passport.authenticate(APIStrategy.STRATEGY_NAME, {
		session: false
	}),
	function(req, res) {
		var appIdAuthContext = req.appIdAuthorizationContext;
		var username = "Anonymous";
		if (appIdAuthContext.identityTokenPayload){
			username = appIdAuthContext.identityTokenPayload.name;
		}
		logger.debug(req.appIdAuthorizationContext);
		res.send("Hello from protected resource " + username);
	}
);

var port = process.env.PORT || 1234;

app.listen(port, function(){
{'fraction_non_alphanumeric': 0.1462925851703407, 'fraction_numerical': 0.028056112224448898, 'mean_word_length': 5.701342281879195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6312314', 'n_tokens_mistral': 724, 'n_tokens_neox': 664, 'n_words': 120}