Skip to content

jeromemaloberti/ocaml-github

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Library

This library provides an OCaml interface to the Github JSON API. It is not yet complete, but look in lib/github.atd for the specification that has been implemented so far. The full API details can be found at: http://developer.github.com/v3/

There are several tests in lib_test for small bits of functionality, and for the authenticated ones you will need to edit lib_test/config.ml with suitable auth information. Use the get_token test to obtain an oAuth token for the config file.

Cookie jar

Applications that use this library will need to save authentication tokens locally, and the Github_cookie_jar module in the unix/ directory helps handle this more naturally. It maps an authentication token onto a local application name, which can then query that token at runtime and use it in Github API calls.

The tokens are all stored in $HOME/.github/<name>, where <name> is the local name of the application.

A git-jar command is also installed to add, remove and list the contents of this cookie jar.

$ git jar

...will display the man page.

$ git jar show avsm
Enter Github password: **********                                                                                                                                                                                                                                               
Cookie Name | ID       | Application                              | Note      
----------------------------------------------------------------------------------
   <remote> | 236241   | Real World OCaml                         |           
   <remote> | 340988   | Travis                                   |           

Note that the cookies are all current remote. To save the Real World OCaml one to local storage so that an application can use it, just do:

$ git jar save avsm 236241 rwo
Enter Github password: **********                                                                                                                                                                                                                                               
Github cookie jar: created /Users/avsm/.github/jar/rwo

This will now show up in the show command as a local cookie:

$ git jar show avsm
Enter Github password: **********                                                                                                                                                                                                                                               
Cookie Name | ID       | Application                              | Note      
----------------------------------------------------------------------------------
        rwo | 236241   | Real World OCaml                         |           
   <remote> | 340988   | Travis                                   |           

Your Github application can how use it via the Github_cookie_jar module:

# #require "github.unix";;
# Github_cookie_jar.get ~name:"rwo";;
- : Github_t.auth option = Some 
  { Github_t.auth_scopes = [`Public_repo];
    Github_t.auth_token = "<token>";
    Github_t.auth_app = {
      Github_t.app_name = "Real World OCaml";
      Github_t.app_url = "http://realworldocaml.org/" };
    Github_t.auth_url = "https://api.github.com/authorizations/236241";
    Github_t.auth_id = 236241; Github_t.auth_note = None; 
    Github_t.auth_note_url = None }

About

Github APIv3 OCaml bindings

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • OCaml 100.0%