Get target host in python post plugin

My target url for an api is an AWS Lambda URL. It requires an AWS authentication header. The target URL is required to generate a proper token. The host header in the post middleware is the tyk host not the target. I have gotten around the issue by putting the proper host value in config data. It would be better however if the target host was available to the plugin

Hi @ScottFN, great getting this to work. However, you could also use the proxy target_url from the plugin to also generate your token.

Hi Olu,
How would I reference that value. Is it available from the request object? Is there a definition of the full request object? I have not found one it the documentation.

There isn’t a proxy defined for this API. Are you suggesting that I define one just to pass this value?
Thanks
Scott

@ScottFN ,

the target URL is available on the API definition under the spec arg in the method.

Read about it here.

Have you tried that?

spec[‘proxy’] and spec[‘target_url’] both come up as empty strings. Is there a different way to access them?

@ScottFN My error. It seems using config_data is the only way this works.

I assumed the spec contained the whole API definition. Converting the spec to string shows it only contains 4 properties below

{
	"config_data": "{}",
	"OrgID": "63491e8aed24600080342f41",
	"bundle_hash": "56e0fa2de371bae49e1360a716855fa7",
	"APIID": "4dc7f224902948ba58f7f7a701c2bd0e"
}

I think in golang plugins, there is a way to get the API from the api_id. But Python does not have access to the internals of Tyk. Apologies for leading you off.

Any chance that is on the radar for a correction?

Unfortunately no. It’s actually by design.