js reminder, fetch auth stuff
This commit is contained in:
parent
802efbe286
commit
85fc4ca5ca
4 changed files with 15 additions and 8 deletions
1
main.py
1
main.py
|
@ -7,3 +7,4 @@
|
||||||
import requests, sqlite3, json
|
import requests, sqlite3, json
|
||||||
from mastodon import Mastodon
|
from mastodon import Mastodon
|
||||||
|
|
||||||
|
cfg = json.load(open('meta.json'))
|
||||||
|
|
|
@ -35,8 +35,6 @@ async function ajax(url) { //must be called from an async function! use 'await',
|
||||||
|
|
||||||
async function cont() {
|
async function cont() {
|
||||||
url = dgel('instance-input').value;
|
url = dgel('instance-input').value;
|
||||||
if (url.substr(0,8) != "https://") {
|
j = await ajax('/internal/auth_a?url=' + url)
|
||||||
url = "https://" + url
|
console.log(j)
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,6 +9,9 @@
|
||||||
<body>
|
<body>
|
||||||
<h1>Curious Greg</h1>
|
<h1>Curious Greg</h1>
|
||||||
<h2>Connect your Curious Cat and Mastodon accounts for automated crossposting.</h2>
|
<h2>Connect your Curious Cat and Mastodon accounts for automated crossposting.</h2>
|
||||||
|
<noscript>
|
||||||
|
Curious Greg will not function without JavaScript. Please ensure you have JavaScript enabled.
|
||||||
|
</noscript>
|
||||||
<!-- <div id='logo-main'></div> -->
|
<!-- <div id='logo-main'></div> -->
|
||||||
<form onsubmit='cont(); return false'>
|
<form onsubmit='cont(); return false'>
|
||||||
<label for='instance'>Instance URL</label><br />
|
<label for='instance'>Instance URL</label><br />
|
||||||
|
@ -17,6 +20,7 @@
|
||||||
</form>
|
</form>
|
||||||
<div id='footer'>
|
<div id='footer'>
|
||||||
Note that Curious Greg requires first-party cookies to be enabled. You may safely delete the cookie upon completing the connection process.
|
Note that Curious Greg requires first-party cookies to be enabled. You may safely delete the cookie upon completing the connection process.
|
||||||
|
Curious Greg will not function without JavaScript. Please ensure you have JavaScript enabled.
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
12
web.py
12
web.py
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import requests, sqlite3, json
|
import requests, sqlite3, json
|
||||||
from mastodon import Mastodon
|
from mastodon import Mastodon
|
||||||
from flask import Flask, render_template
|
from flask import Flask, render_template, request
|
||||||
|
|
||||||
cfg = json.load(open("meta.json"))
|
cfg = json.load(open("meta.json"))
|
||||||
|
|
||||||
|
@ -24,14 +24,18 @@ def main():
|
||||||
|
|
||||||
@app.route('/internal/auth_a')
|
@app.route('/internal/auth_a')
|
||||||
def internal_auth_a():
|
def internal_auth_a():
|
||||||
|
|
||||||
|
client_id = "abc"
|
||||||
|
client_secret = "123"
|
||||||
|
instance_url = request.args.get('url', default='mastodon.social', type=str)
|
||||||
|
if not instance_url.startswith("https://"):
|
||||||
|
instance_url = "https://{}".format(instance_url)
|
||||||
|
|
||||||
# client_id, client_secret = Mastodon.create_app(cfg['name'],
|
# client_id, client_secret = Mastodon.create_app(cfg['name'],
|
||||||
# api_base_url=instance_url,
|
# api_base_url=instance_url,
|
||||||
# scopes="write:statuses",
|
# scopes="write:statuses",
|
||||||
# website=cfg['website'])
|
# website=cfg['website'])
|
||||||
|
|
||||||
client_id = "abc"
|
|
||||||
client_secret = "123"
|
|
||||||
|
|
||||||
client_info = {
|
client_info = {
|
||||||
"client_id": client_id,
|
"client_id": client_id,
|
||||||
"client_secret":client_secret,
|
"client_secret":client_secret,
|
||||||
|
|
Loading…
Reference in a new issue