OAuthPlugin icon

OAuthPlugin -----

A user manager for oauth endpoint.



## ✨ Features

OAuth2 Flows
• /discord → identify your Discord account
• /patreon → verify your Patreon pledge
• /code <AUTH_CODE> → finalize linking

Data Storage
• PostgreSQL via HikariCP
• Auto-create database & users table

Developer API
• UserManager: createUser, cacheUser, getUserByDiscordId, getUserByPatreonId, getUserByMinecraftId
• User interfaces for DiscordUser, PatreonUser, MinecraftUser
• OAuthService for Patreon profile fetch
• OAuthUserSession to track pending flows

Extensible
• Add new OAuth providers (Twitch, LinkedIn, OpenAI…)
• Register event listeners for user data changes

---

## Requirements

- Java 11+
- Spigot or Paper 1.16+
- PostgreSQL 9.6+
- Internet connectivity for OAuth
- (Optional) ngrok or public hosting for callback URLs

---

## Installation

1. Download the latest JAR from [GitHub]( https://github.com/brandongrahamcobb/OAuthPlugin/releases/download/v1.0.0/OAuthPlugin-0.1.jar).
2. Place `OAuthPlugin.jar` into your server’s `plugins/` folder.
3. Start the server once to generate `plugins/OAuthPlugin/config.yml`.
4. Stop the server.

[​IMG]

---

## ⚙ Configuration

Open `plugins/OAuthPlugin/config.yml` and fill in your credentials:

Code (YAML):

# PostgreSQL
POSTGRES_HOST
:     "localhost"
POSTGRES_PORT
:     "5432"
POSTGRES_DATABASE
: "oauth_db"
POSTGRES_USER
:     "oauth_user"
POSTGRES_PASSWORD
: "secret"

# Enable
ENABLE_DISCORD
: true
ENABLE_PATREON
: true

# Discord OAuth2
DISCORD_CLIENT_ID
:     "<id>"
DISCORD_CLIENT_SECRET
: "<secret>"
DISCORD_REDIRECT_URI
: "https://example.com:8000/oauth/discord_callback"

# Patreon OAuth2
PATREON_CLIENT_ID
:     "<id>"
PATREON_CLIENT_SECRET
: "<secret>"
PATREON_REDIRECT_URI
: "https://example.com:8000/oauth/patreon_callback"

# Embedded HTTP (Spark)
SPARK_PORT
:              8000
SPARK_DISCORD_ENDPOINT
:   "/oauth/discord_callback"
SPARK_PATREON_ENDPOINT
:   "/oauth/patreon_callback"
 
Reload your server. You should see in console:

---

## OAuth Flow

1. Player runs:
Code (Text):
/discord
or
Code (Text):
/patreon
→ They receive a URL:

[​IMG]

2. Player visits URL, authorizes, and is redirected to your Spark callback:
3. Back in-game:
Code (Text):
/code AUTH_CODE
→ Plugin exchanges code for token, fetches profile, updates database.

---

## In-Game Commands

| Command | Usage |
|----------------------|-------------------------------------------------|
| /discord | Generate Discord OAuth2 link |
| /patreon | Generate Patreon OAuth2 link |
| /code <AUTH_CODE> | Complete pending link (Discord or Patreon) |

---

## Developer API

Add dependency:

**Maven**
```xml
<dependency>
<groupId>com.brandongcobb.oauthplugin</groupId>
<artifactId>OAuthPlugin</artifactId>
<version>1.0.0</version>
</dependency>
```
**Gradle**
```gradle
implementation 'com.brandongcobb.oauthplugin:OAuthPlugin:1.0.0'
```
Initialize:
```java
Database db = Database.completeGetInstance();
UserManager um = new UserManager(db);
```
Fetch a user by Discord ID:
```java
User user = um.getUserByDiscordId(123456789012345678L);
if (user != null) {
System.out.println("Patreon Tier: " + user.getPatreonTier());
}
```
Full API docs:
https://brandongrahamcobb.github.io/OAuthPlugin/javadoc/

---

## Documentation & Support

- [GitHub Repository]( https://github.com/brandongrahamcobb/OAuthPlugin)
- [Wiki & Guides]( https://github.com/brandongrahamcobb/OAuthPlugin/wiki)
- [Issue Tracker]( https://github.com/brandongrahamcobb/OAuthPlugin/issues)
- [Discord Support]( https://discord.gg/3prMme6YA8)

---

## AI-Generated Visual Guides

To help you set up and configure OAuthPlugin, we’ve created AI-generated step-by-step visuals:

1. [Plugin Folder Setup]( https://brandongcobb.com/static/media/plugins.png)
2. [Editing config.yml]( https://brandongcobb.com/static/media/edit-config.png)
3. [Running ngrok for public callbacks]( https://brandongcobb.com/static/media/ngrok.png)

---

## License

Licensed under the [GNU General Public License v3.0]( https://www.gnu.org/licenses/gpl-3.0.html).

Enjoy secure, seamless integration of Discord and Patreon into your Minecraft community!
Resource Information
Author:
----------
Total Downloads: 16
First Release: May 17, 2025
Last Update: May 17, 2025
Category: ---------------
All-Time Rating:
0 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings