Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 10 days ago
JSON representation
A proxy service that uses Discord OAuth 2.0 authentication powered by Hono
- Host: GitHub
- URL: https://github.com/sakkke/oauth2-discord-proxy
- Owner: sakkke
- License: mit
- Created: 2024-03-08T07:18:45.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-04-13T07:01:19.000Z (8 months ago)
- Last Synced: 2024-11-13T16:34:13.624Z (about 1 month ago)
- Topics: authentication, discord, hono, honojs, oauth2, proxy, proxy-server, proxy-service
- Language: TypeScript
- Homepage:
- Size: 75.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)