我想使用以下grails插件来使用Google shorten url API。
http://www.grails.org/plugin/rest
问题是,我需要使用代理身份验证设置(带有用户名和密码) API给我setProxy,但没有用户名和密码设置。
如何在此处设置代理身份验证详细信息?
如果还有其他选择,请告诉我。我不能使用google-url-shortener插件,因为我还在使用grails 1.2.0,它与插件不兼容。
谢谢,罗伯特
发布于 2011-10-25 14:13:51
您可以尝试将Proxy-Authorization标头设置为向代理进行身份验证。类似于下面的内容:
withRest(id: "urlshortener",
requestContentType: JSON,
body: [longUrl: "http://www.google.com/"]
proxy: [host: "myproxy.acme.com", port: 8080, scheme: "http"]) {
def response = post(path: '/urlshortener/v1/url') {
headers.'Proxy-Authorization' = 'Basic ' +
"${username}:${password}".toString().bytes.encodeBase64()
}
}https://stackoverflow.com/questions/7874532
复制相似问题