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

AI-generated summary

Lid proposed updates to the Onebox GitHub integration to address API rate limits and enhance functionality. To avoid hitting the 60 requests-per-hour limit when fetching commit or pull request data, Lid implemented support for authenticated API requests via Onebox.options. This configuration supports both OAuth tokens (recommended) and basic username/password authentication, allowing for the retrieval of build statuses and pull request details. The proposal included visual examples of the new pull request and build status displays. Additionally, Lid introduced new styling for the onebox. Following this, zogstrip noted that some information and styling were subsequently removed from the pull request onebox to prevent the data from becoming outdated quickly, referencing the implementation in the main Discourse repository.

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

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.

6개의 좋아요

New styling


https://github.com/discourse/onebox/pull/241?1

2개의 좋아요

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

https://github.com/discourse/discourse/pull/2874

3개의 좋아요