因此,我有这个工作请求,使用HTTPBsaicAuth,需要通过Apigee.我配置了我的Apigee代理与基本Auth检索标题中的用户名和密码,但我仍然得到错误:
{"fault":{"faultstring":"Gateway Timeout","detail":{"errorcode":"messaging.adaptors.http.flow.GatewayTimeout"}}}
下面是没有Apigee通行证的原始请求:
import requests
from requests.auth import HTTPBasicAuth
url = "https://myapi.com/path"
auth = HTTPBasicAuth("username", "password")
response = requests.get(url, auth=auth, verify=False)
上面的请求工作没有问题。我的新请求,包括Apigee url和apikey在头中:
import requests
from requests.auth import HTTPBasicAuth
url = "https://apigee-proxy.com/basepath/path"
headers = {
"apikey" : "XXXXXX",
"username": "username",
"password": "password"
}
response = requests.get(url, headers=headers, verify=False)
代理设置,非常基本:
<ProxyEndpoint name="default">
<Description/>
<FaultRules/>
<PreFlow name="PreFlow">
<Request/>
<Step>
<Name>Extract-Variables-1</Name>
</Step>
<Step>
<Name>Basic-Authentication-1</Name>
</Step>
<Response/>
</PreFlow>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<Flows>
</Flows>
<HTTPProxyConnection>
<BasePath>/basepath</BasePath>
<Properties/>
<VirtualHost>default</VirtualHost>
</HTTPProxyConnection>
<RouteRule name="default">
<TargetEndpoint>default</TargetEndpoint>
</RouteRule>
</ProxyEndpoint>
已更新:提取变量-1.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-1">
<Source>request</Source>
<Header name="username">
<Pattern ignoreCase="true">{username}</Pattern>
</Header>
<Header name="password">
<Pattern ignoreCase="true">{password}</Pattern>
</Header>
<VariablePrefix>auth</VariablePrefix>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
</ExtractVariables>
基本身份验证1策略:
<BasicAuthentication async="false" continueOnError="true" enabled="true" name="Basic-Authentication-1">
<DisplayName>Basic Authentication-1</DisplayName>
<Operation>Encode</Operation>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<User ref="auth.username"/>
<Password ref="auth.password"/>
<AssignTo createNew="false">request.header.Authorization</AssignTo>
</BasicAuthentication>
默认路由规则:
<TargetEndpoint name="default">
<Description/>
<FaultRules/>
<PreFlow name="PreFlow">
<Request/>
<Response/>
</PreFlow>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<Flows/>
<HTTPTargetConnection>
<LoadBalancer>
<Server name="my_target"/>
</LoadBalancer>
<Path>/</Path>
</HTTPTargetConnection>
</TargetEndpoint>
目标服务器环境变量“my_target”= myapi.com,端口=443
有什么我错过了吗?任何帮助都是感激不尽的。
更新:代理现在包括Extract-Variables-1,我可以看到正在应用身份验证头,但仍超时..:
1条答案
按热度按时间pgvzfuti1#
我认为您缺少的是“提取变量”策略。请尝试提取用户和口令值并传递获得的值。
比如
并将其用作