Onebox - Github - API Authentication & pull request and build status

https://github.com/discourse/onebox/pull/238

##Github authenticated api requests

Onebox when using the github api to fetch information about a commit or a pull request
is currently using unauthenticated request.
While I was developing and testing new pull request functionality. I quickly reached the 60 requests limit per hour.

So I implemented authentication for github api requests.
the method and credentials can be passed using the Onebox.options

Two authentication methods are supported

  • oauth token
  • username and password (not recommended)
Onebox.options ={:GithubPullRequestOnebox => {
                                :github_auth_token => "<token>",
                                :github_auth_user  => "<user>",
                                :github_auth_pass  => "<pass>",
                                :github_auth_method =>:oauth, # :basic | :oauth | nil

                                :get_build_status  => true
                                }
}

Two authentication methods are supported

  • oauth token
  • username and password (not recommended)

###Generating a github oauth token for an application
oauth is the recommended way since you do not expose your password, and full privileges.and you can generate one without any scopes. if you only use it for public repositories
https://github.com/settings/tokens/new

Show pull status and build status,

When this is activated in the box options it will make an additional request to get the build status.

5 Likes

New styling


2 Likes

FTR I just removed some of the info and styling from the pull request onebox so that they don’t rot too quickly :wink:

2 Likes