Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions ovos_config_assistant/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,31 @@ def oauth_callback(oauth_id):
params = dict(request.args)
code = params["code"]

data = JsonStorageXDG("ovos_oauth_apps")[oauth_id]
client_id = data["client_id"]
client_secret = data["client_secret"]
token_endpoint = data["token_endpoint"]

# Prepare and send a request to get tokens! Yay tokens!
client = WebApplicationClient(client_id)
token_url, headers, body = client.prepare_token_request(
token_endpoint,
authorization_response=request.url,
redirect_url=request.base_url,
code=code
)
token_response = requests.post(
token_url,
headers=headers,
data=body,
auth=(client_id, client_secret),
).json()

with JsonStorageXDG("ovos_oauth") as db:
db.add_token(oauth_id, token_response)
with JsonStorageXDG("ovos_oauth_apps") as oauth_store:
data = oauth_store[oauth_id]
client_id = data["client_id"]
client_secret = data["client_secret"]
token_endpoint = data["token_endpoint"]

# Prepare and send a request to get tokens! Yay tokens!
client = WebApplicationClient(client_id)
token_url, headers, body = client.prepare_token_request(
token_endpoint,
authorization_response=request.url,
redirect_url=request.base_url,
code=code
)
token_response = requests.post(
token_url,
headers=headers,
data=body,
auth=(client_id, client_secret),
).json()
data['token_response'] = token_response

return params


def main(port=36535, debug=True):
app.run(port=port, debug=debug)
def main(host='0.0.0.0', port=36535, debug=True):
app.run(host=host, port=port, debug=debug)
# start_server(start, port=port, debug=debug)
3 changes: 2 additions & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ ovos_utils
pywebio
cutecharts
oauthlib~=3.0
ovos_backend_client
ovos_backend_client
flask~=2.2