[英]Change curl to httparty Rails
您能幫我將以下命令轉換為httparty嗎?
curl -u username:token https://api.github.com/user
我嘗試了以下操作,但是我收到了需要驗證錯誤的提示。
class GitApi
include HTTParty
base_uri 'https://api.github.com'
def initialize
@auth = { :username => "username", :token => "token" }
end
def user
self.class.get("/user", @auth)
end
end
class GitApi
include HTTParty
base_uri 'https://api.github.com'
basic_auth 'username', 'token'
def user
self.class.get("/user")
end
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.