Hi Team...
I am facing an issue while accessing OAuth context variables in Gateway script (APIC 10.0.5.2). The API is being tested by the below approach,
1. Developed OAuth provider API with application flow. (Working fine)
2. Configured external metadata URL to collect metadata and return in access token. (Working fine)
3. Developed a business API and attached the above OAuth security to it. In the API assembly, I am trying to extract the OAuth metadata(from incoming OAuth access token) to check its content for validation using Gateway script, but, unable to extract it using OAuth context variables and it reports error as undefined. Please help on extracting the OAuth metadata variable value from the incoming acces token in Gateway script.
var apim = require('apim');
//Start with reading the incoming JSON message
session.INPUT.readAsJSON(function (error, json) {
console.error("Request: %j", JSON.stringify(json));
if (error){
session.reject( 'Invalid JSON Request Structure' );
return;
} else {
var check = context.get('oauth.processing.verified_access_token.misc_info'); - Not working
var check1 = context.get('oauth.miscinfo'); - Not working
console.error("token metadata %s", check);
var checkStr = check.toString().replace("m:","");
context.message.header.set ('oauth-meta-data', checkStr);
var jsonmetadata = JSON.parse(checkStr);
var consentExpiry = jsonmetadata.CONSENT_EXPIRY;
console.error("token metadata %s", consentExpiry);
}
});
------------------------------
Ashok Beshra
------------------------------