Use oauth_iparams with "agent" OAuth type

Hey @zach_jones_noel,

Thank you for the quick reply. Sure thing. My oauth_config.json looks like:

{
	"client_id": "freshworks_dev",
	"client_secret": "********",
	"authorize_url": "https://server4.gak.islonline-dev.com/users/authz/oauth2/grant",
	"token_url": "https://server4.gak.islonline-dev.com/authz/oauth2/token",
	"options": {
		"scope": "read_session_id"
	},
	"token_type": "agent"
}

The token is used in callOAuth2App request defined like this in requests.json:

{
    "callOAuth2App": {
        "schema": {
            "method": "POST",
            "host": "server4.gak.islonline-dev.com",
            "path": "/webapi2",
            "query": {
                "he": "JSON1",
                "method": "<%= context.method %>",
                "hs": "<%= context.hs %>"
            },
            "headers": {
                "Authorization": "Bearer <%= access_token %>",
                "Content-Type": "application/json"
            }
        },
        "options": {
            "isOAuth": true
        }
    }
}

And finally I make the call from app.js like so:

client.request.invokeTemplate("callOAuth2App", { 
	context: {
		method: "integrator/oauth2/user/login/1",
		hs: sid
	},
	body: JSON.stringify({jwt: r.response})
}).then(async function (r) {
	console.log("OK", r);
}).catch((err) => {
	// TODO: How do I handle 401 on revoked token
	console.log("err", err);
});

This all works as expected. The OAuth2 “handshake” completes and the app is authorized on first open/use. I am also able to use the token to make requests.

I was just a bit surprised that I was not able to use oauth_iparams with the agent token type.

Best regards,
Gasper