Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sakkke/oauth2-discord-proxy

A proxy service that uses Discord OAuth 2.0 authentication powered by Hono
https://github.com/sakkke/oauth2-discord-proxy

authentication discord hono honojs oauth2 proxy proxy-server proxy-service

Last synced: 13 days ago
JSON representation

A proxy service that uses Discord OAuth 2.0 authentication powered by Hono

Awesome Lists containing this project

README

        

# oauth2-discord-proxy

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/sakkke/oauth2-discord-proxy/bun.yml)

## Description

`oauth2-discord-proxy` is a proxy service that uses Discord OAuth 2.0 authentication powered by [honojs/hono](https://github.com/honojs/hono).
The motivation for this project is adding Discord authentication to services that do not have authentication functionality.

## Installation

### bun

```
bun install oauth2-discord-proxy
```

### npm

```
npm install oauth2-discord-proxy
```

## Usage

First, create a new `Hono` instance and add a route with `createProxy()`.

```js
import { Hono } from 'hono'
import { createBot, createProxy } from 'oauth2-discord-proxy'
import { client_id, client_secret, discord_guild_id, discord_token, oauth2_callback, oauth2_endpoint } from './config.json'

const app = new Hono()

app.route('/', createProxy({
bot: createBot(discord_token),
client_id,
client_secret,
discord_guild_id,
oauth2_callback,
oauth2_endpoint,
}))

app.get('/', c => c.text('ok'))
```

Finally, serve a application.

```js
import { serve } from 'bun'
import { port } from './config.json'

serve({
fetch: app.fetch,
port,
})

console.log(`listening at http://0.0.0.0:${port}`)
console.log(`login: http://0.0.0.0:${port}/login`)
```

Also, example code is [here](./src/server.js).

## License

[MIT](./LICENSE)