Discord-OAuth2
A set up to assign roles with Stripe in Discord and allow access via OAuth2. Intended for use with PMSF.
Requirements:
- Ubuntu 16.04
- Python3.6
- nginx
- A Discord bot with proper permissions. Here is a link on how to set it up: https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token
How to install:
sudo apt-get install php-sqlite3
cd var/www/html/xxxx
git clone git@gitlab.com:dan.r.neal/Discord-OAuth2.git
cd ./Discord_OAuth2
python3.6 -m pip install virtualenv
python3.6 -m virtualenv env
source env/bin/activate
python3.6 -m pip install -r requirements.txt
deactivate
Stripe
- Add new product with a new pricing plan. Copy plan id into the config in the next section.
- Create a new webhook endpoint at
https://xxx/subscribe/webhooks
with the following events enabled and copy the webhook key into the config in the next section.
charge.succeeded
customer.updated
customer.subscription.created
customer.subscription.deleted
customer.subscription.updated
invoice.payment_failed
invoice.upcoming
How to set up:
- Rename
config.ini.example
toconfig.ini
in the config folder. - Set all required variables in config file.
- Set your redirect uri in your discord developer console, it should match the same value set in the config file.
- Copy the header of
index.php
in the setup folder into your current PMSFindex.php
. sudo chown -R www-data:www-data /var/www/html/xxx/Discord-OAuth2/
- Update your nginx config file in
/etc/nginx/sites-enabled
with the settings inexample.conf
in the setup folder. systemctl restart nginx
- Move
xxx_oauth2.service
from the setup folder to/etc/systemd/system
. systemctl enable xxx_oauth2
- Change any items desired in /templates and /static
How to run/restart:
- To run:
systemctl start xxx_oauth2
- To restart:
systemctl restart xxx_oauth2
- To view logs:
journalctl -u xxx_oauth2 -f
Credit:
Thanks to Glennmen for PMSF