我正在尝试使用节点模块请求在网站上进行身份验证,按照说明进行操作后,我似乎仍然无法弄清楚...
使用 Coffeescript 我做了以下事情:
Request {
url: "https://#{encodeURIComponent(config.email)}:#{encodeURIComponent(config.password)}@#{config.loginURL}"
}, (error, response, body) ->
if error
console.log error
else
console.log body
这些config
值分别是电子邮件、密码和 URL。网址是app.shopify.com/services/partners/auth/login
。另外,因为用户名是电子邮件地址,所以我认为最好encodeURIComponent
使用登录值。
当我运行它时,我没有收到错误,但输出body
只是登录页面的标记。
我也试过这样做:
Request.get config.loginURL, {
auth: {
username: config.email
password: config.password
sendImmediately: false
}
}, (error, response, body) ->
if error
console.log error
else
console.log body
在这种情况下,因为凭据不是 URL 的一部分,所以我没有encodeURIComponent
'd 他们。此外,登录 URL 已https://
添加到它前面。
谁能指导我正确的方向?