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

**URL:** <https://meta.discourse.org/t/onebox-github-api-authentication-pull-request-and-build-status/20389>\
**Category:** Feature\
**Created:** [Septembre 24, 2014, 6:23 UTC](https://meta.discourse.org/t/onebox-github-api-authentication-pull-request-and-build-status/20389 "2014-09-24T06:23:06Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Lid](https://avatars.discourse-cdn.com/v4/letter/l/2bfe46/32.png) [@Lid](https://meta.discourse.org/u/Lid)\
**Post date:** [Septembre 24, 2014, 6:23 UTC](https://meta.discourse.org/t/onebox-github-api-authentication-pull-request-and-build-status/20389/1 "2014-09-24T06:23:07Z")

</div>

[https://github.com/discourse/onebox/pull/238](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)

```ruby
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

> **[Build software better, together](https://github.com/settings/tokens/new)**
>
> GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.

 ![](https://global.discourse-cdn.com/meta/original/3X/2/3/2313b3743d9b99d02ab7e3494e512da0cf22a94d.png)

## 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.

 ![](https://global.discourse-cdn.com/meta/original/3X/1/f/1f5d4303b08cc74cfc5a346567d930c7710ef9d0.png) 

 ![](https://global.discourse-cdn.com/meta/original/3X/b/7/b7600673f37e3610c76693effd2059580b99fbab.png) 

 ![](https://global.discourse-cdn.com/meta/original/3X/e/f/ef4e87c1d78fbbe67647fdc4dda50ca5fe5a4284.png)

---

_[View the full topic](https://meta.discourse.org/t/onebox-github-api-authentication-pull-request-and-build-status/20389)._
