Initial commit.
This commit is contained in:
commit
fb34edc21a
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
# Ignore pycache
|
||||
*/__pycache__/**
|
||||
*.pyc
|
||||
|
||||
# I called my virtual environment "venv", this is so I don't commit it.
|
||||
venv/**
|
7
README.md
Normal file
7
README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# GoToSocial FE
|
||||
|
||||
I'm gonna try to make a GoToSocial front-end. Right now, using Flask.
|
||||
|
||||
# Usage
|
||||
|
||||
`./deploy.sh development` or `./deploy.sh production` to run the Flask server.
|
50
app/app.py
Normal file
50
app/app.py
Normal file
@ -0,0 +1,50 @@
|
||||
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
|
||||
|
12
app/templates/index.html
Normal file
12
app/templates/index.html
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<head>
|
||||
<title>Some kind of Flask App</title>
|
||||
</head>
|
||||
<div>
|
||||
<p>I guess you should input something</p>
|
||||
<a href="/login">login</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
13
deploy.sh
Executable file
13
deploy.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -xe
|
||||
|
||||
FLASK_NAME=flaskoauth
|
||||
FLASK_ENV=$1
|
||||
|
||||
if [ "$FLASK_ENV" == "development" ] || [ "$FLASK_ENV" == "production" ]; then
|
||||
cd app/
|
||||
flask run --host=0.0.0.0
|
||||
else
|
||||
echo "Please use 'development' or 'production' as an argument."
|
||||
fi
|
14
register_app.py
Executable file
14
register_app.py
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from requests import post
|
||||
|
||||
payload={
|
||||
'client_name':'anotherone',
|
||||
'redirect_uris':'localhost:5000'
|
||||
}
|
||||
|
||||
def register_app():
|
||||
resp = post('https://gts.werefox.cafe/api/v1/apps', data=payload)
|
||||
return resp.text
|
||||
|
||||
print(register_app())
|
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@ -0,0 +1,3 @@
|
||||
Authlib>=1.2.0
|
||||
Flask>=2.2.3
|
||||
|
Loading…
Reference in New Issue
Block a user