[英]Authenticate user through GitHub API using Ruby?
我必須通過Ruby中的GitHub API對用戶進行身份驗證,才能創建私有存儲庫。
GitHub手冊顯示了如何使用curl進行操作。
有人可以告訴我如何使用rest-client或octopussy之類的Ruby gem嗎?
像這樣嗎
client = Octokit::Client.new(:login => 'someguy', :token => 'sometoken123b1i3')
client.create(:name=>'foobar', :description=>'Foo Bar', :homepage=> 'http://example.com', :public=>false)
http://github.com/pengwynn/octokit/blob/master/lib/octokit/client.rb#L198
使用RestClient,首先需要創建一個資源,然后使用該資源發布定義回購元數據的JSON數據:
my_resource = RestClient::Resource.new( "https://api.github.com", :user => "username", :password => "123456" )
my_resource["/user/repos"].post( { :name => "new-repo", :description => "this is a new repo", :public => true }.to_json )
有關API的詳細信息,請參見http://developer.github.com/v3/repos/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.