-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8e8a2b
commit d242a46
Showing
4 changed files
with
58 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from dash_auth_external import DashAuthExternal | ||
from dash import Dash, Input, Output, html, dcc | ||
|
||
#using spotify as an example | ||
AUTH_URL = "https://accounts.spotify.com/authorize" | ||
TOKEN_URL = "https://accounts.spotify.com/api/token" | ||
CLIENT_ID = "YOUR_CLIENT_ID" | ||
|
||
# creating the instance of our auth class | ||
auth = DashAuthExternal(AUTH_URL, TOKEN_URL, CLIENT_ID) | ||
server = ( | ||
auth.server | ||
) # retrieving the flask server which has our redirect rules assigned | ||
|
||
|
||
app = Dash(__name__, server=server) # instantiating our app using this server | ||
|
||
##Below we can define our dash app like normal | ||
app.layout = html.Div([html.Div(id="example-output"), dcc.Input(id="example-input")]) | ||
|
||
|
||
@app.callback(Output("example-output", "children"), Input("example-input", "value")) | ||
def example_callback(value): | ||
token = ( | ||
auth.get_token() | ||
) ##The token can only be retrieved in the context of a dash callback | ||
return token | ||
|
||
if __name__ == "__main__": | ||
app.run_server() |