Skip to content

OctobayArchive/api

Repository files navigation

OctoBay API

OctoBay API Dev

Run locally

git clone https://github.com/Octobay/api octobay-api && cd octobay-api && yarn && cp .env.sample .env

Add your GitHub OAuth app credentials and a personal access token to the .env file and run yarn start.

GitHub

GitHub Personal Access Token ### Get a GitHub Personal Access Token

Follow these instructions to get your GitHub Personal Access Token.

Create the token with the following permissions:

  • public_repo
  • user:email

Put this personal access token in the .env file for the GITHUB_PERSONAL_ACCESS_TOKEN variable.

Authorization Access Token

Get an access token for a GitHub user.

Option 1: Create a GitHub OAuth2 App and Get a token using the frontend

Step 1: Create OAuth App

Our frontend and some backend calls (like is-repo-admin) expects an GitHub OAuth2 token.

Let's get you a token.

First create an OAuth2 Github app. Go to Settings -> Developer settings -> OAuth Apps

Set callback url to:

Application Name: anything Homepage url: could be anything, but just do https://octobay.uber.space/ Authorization callback URL: MUST be http://localhost:3000/auth/github

Create the application.

In .env, set the following to your OAuth2 apps information:

GITHUB_CLIENT_ID=<YOUR_GITHUB_CLIENT_ID>
GITHUB_CLIENT_SECRET=<YOUR_GITHUB_CLIENT_SECRET>
Step 2: Login from frontend

Set the following parameters in the app frontend

API_URL=http://localhost:3001
GITHUB_CLIENT_ID=<THE CLIENT ID OF THE OUATH2 APP YOU CREATED IN STEP 1>

Boot the api and app, and follow the login on the frontend.

You should now have an OAuth2 token beginning with gho_ in you Applications -> Local Storage.

Use this with a header of Authorization : Bearer <YOUR TOKEN> to make authenticated API calls.

Option 2: Intercept Authorization Code

The auth code from https://github.com/login/oauth/authorize can be exchanged for an access token here.

POST /github/access-token

Body

Parameter Default Description
code null The auth code from the GitHub redirect.

Response

Code Type Description
200 String The GitHub user's access token.
500 Object The error object. The code was probably wrong or expired.
User

Get GitHub.

Get a user by username.

GET /github/user/:username

Parameters

Parameter Default Description
username null A GitHub username.

Response

Code Type Description
200 Object The GitHub user's account data.
404 Object User not found.
500 Object GitHub error.

The Graph

Issues

Get all Issues.

Get all issues that are currently indexed in the OctoBay subgraph. Results are cached.

GET /graph/issues

Query

Parameter Default Description
filter null (Not yet implemented yet)
order desc (Not yet implemented yet)
orderBy depositSize (Not yet implemented yet)

Response

Code Type Description
200 Array An array of issues/bounties.
500 Object The error object. Calling the graph endpoint failed.