# 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:** [September 24, 2014, 6:23am 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:** 4
**Page:** 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: [September 24, 2014, 6:23am 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)

---

<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: [September 29, 2014, 4:23am UTC](https://meta.discourse.org/t/onebox-github-api-authentication-pull-request-and-build-status/20389/2 "2014-09-29T04:23:26Z")

</div>

New styling

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

* * *

[https://github.com/discourse/onebox/pull/241?1](https://github.com/discourse/onebox/pull/241?1)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 5, 2014, 10:31pm UTC](https://meta.discourse.org/t/onebox-github-api-authentication-pull-request-and-build-status/20389/3 "2014-10-05T22:31:35Z")

</div>



---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [October 15, 2014, 9:07pm UTC](https://meta.discourse.org/t/onebox-github-api-authentication-pull-request-and-build-status/20389/4 "2014-10-15T21:07:15Z")

</div>

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

[https://github.com/discourse/discourse/pull/2874](https://github.com/discourse/discourse/pull/2874)
