您能帮我将以下命令转换为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
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句