from flask import Flask, render_template, url_for, redirect, request from authlib.integrations.flask_client import OAuth from secrets import token_urlsafe from requests import post app = Flask(__name__) SECRET_KEY = token_urlsafe(32) app.secret_key = SECRET_KEY oauth = OAuth(app) gotosocial = oauth.register( name='gotosocial', # 010DGVDVM5ZN0D8W9WM0X59YMD # 01JFPCR4Q8FYP273DPCW8FGDMJ client_id='010DGVDVM5ZN0D8W9WM0X59YMD', # 917ab929-90f5-4c87-b902-be6bed0d3a4e # 5c190ea8-1984-4e05-b610-d7ed4d241079 client_secret='917ab929-90f5-4c87-b902-be6bed0d3a4e', access_token_url='https://gts.werefox.cafe/oauth/token', access_token_params={'response_type':'token', 'grant_type':'authorization_code', 'client_id':'010DGVDVM5ZN0D8W9WM0X59YMD', 'client_secret':'917ab929-90f5-4c87-b902-be6bed0d3a4e'}, authorize_url='https://gts.werefox.cafe/oauth/authorize', authorize_params={'grant_type':'authorization_code'}, api_base_url='https://gts.werefox.cafe/api', client_kwargs={'scope': 'read'}, ) @app.route('/') def index(): return render_template('index.html') @app.route('/login') def login(): redirect_uri = url_for('authorize', _external=True) return gotosocial.authorize_redirect(redirect_uri) @app.route('/authorize') def authorize(): token = gotosocial.authorize_access_token() print(token) response = gotosocial.get( 'api/v1/accounts/verify_credentials', token=token) response.raise_for_status() account_info = response.json() return account_info