Closed timelessnesses closed 2 years ago
I am playing around with flask-discord. I am having problems with authenication. Here's code if it help.
import os from flask import Flask, redirect, url_for, request, render_template, jsonify, send_from_directory from flask_discord import DiscordOAuth2Session, requires_authorization, Unauthorized app = Flask(__name__) app.config["DISCORD_CLIENT_ID"] = 912743909959020617 app.config["DISCORD_CLIENT_SECRET"] = "client secret here" app.config["DISCORD_REDIRECT_URI"] = "http://localhost:5000/dr" try: with open('token.txt', 'r') as f: token = f.read() except FileNotFoundError: token = input("Enter token: ") with open('token.txt', 'w') as f: f.write(token) app.config["DISCORD_BOT_TOKEN"] = token print(token) discord = DiscordOAuth2Session(app,app.config["DISCORD_CLIENT_ID"],app.config["DISCORD_CLIENT_SECRET"],bot_token=app.config["DISCORD_BOT_TOKEN"]) @app.route('/') def index(): open('log.txt','w').write(str(discord.fetch_guilds())) return render_template('index.html',servers=len(discord.fetch_guilds()),users=len(discord.fetch_users())) @app.route('/css/<file>') def css(file): return send_from_directory('static/css', file) @app.route('/assets/<file>') def assets(file): return send_from_directory('static/assets', file) @app.route('/js/<file>') def js(file): return send_from_directory('static/js', file) app.run(debug=True)
you want to change that client secret - a web hook posted your code snippet as it was.
you have no authentication routes.
I am playing around with flask-discord.
I am having problems with authenication. Here's code if it help.