使用带有代理身份验证的 Grails Rest 插件?

发布于 2024-12-11 10:49:37 字数 347 浏览 0 评论 0原文

我想使用以下 grails 插件来使用 Google 缩短 url API。

http://www.grails.org/plugin/rest

问题是我需要使用它具有代理身份验证设置(带有用户名和密码) API 为我提供了 setProxy,但没有用户名和密码设置。

如何在此处设置我的代理身份验证详细信息?

让我知道是否还有其他选择。我无法使用 google-url-shortener 插件,因为我仍在使用与该插件不兼容的 grails 1.2.0。

谢谢, 罗伯特

I would like to use the following grails plugin to use Google shorten url API.

http://www.grails.org/plugin/rest

The problem is I need to use it with proxy authentication setting (with username and password)
The API gives me setProxy, but without username and password setting.

How can I set my proxy authentication detail here?

Let me know if there is another alternative. I can't use google-url-shortener plugin because I'm still using grails 1.2.0 which is not compatible with the plugin.

Thanks,
Robert

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唐婉 2024-12-18 10:49:37

您可以尝试设置 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()
    }
}

You could try setting the Proxy-Authorization header to authenticate to the proxy. Something similar to the following:

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()
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文