Skip to content

Commit

Permalink
Update python oauth app style
Browse files Browse the repository at this point in the history
  • Loading branch information
dbkegley committed Jun 7, 2024
1 parent 4a58422 commit ffb3dde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions local/python-oauth-integration-app/app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# -*- coding: utf-8 -*-
# mypy: ignore-errors
import os
import json

import jwt
from posit.connect.client import Client
from shiny import App, Inputs, Outputs, Session, render, ui

SQL_HTTP_PATH = os.getenv("DATABRICKS_PATH")

app_ui = ui.page_fluid(ui.output_text_verbatim("text"))
app_ui = ui.page_fluid(
ui.row(ui.output_text_verbatim("text"),
style='background-color: #f6f6f6; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; height: 12em; width: 60%'))

def server(input: Inputs, output: Outputs, session: Session):
"""
Expand All @@ -23,7 +25,8 @@ def server(input: Inputs, output: Outputs, session: Session):
def text():
with Client() as client:
credentials = client.oauth.get_credentials(session_token)
return credentials.get("access_token")
token = jwt.decode(jwt=credentials.get("access_token"), options={"verify_signature": False})
return json.dumps(token, indent=4)


app = App(app_ui, server)
1 change: 1 addition & 0 deletions local/python-oauth-integration-app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ databricks-sql-connector==3.0.1
databricks-sdk==0.20.0
shiny==0.7.1
posit-sdk==0.2.0
PyJWT==2.8.0

0 comments on commit ffb3dde

Please sign in to comment.