diff --git a/README.md b/README.md index 9aea0f9..5f163b8 100644 --- a/README.md +++ b/README.md @@ -16,16 +16,42 @@ pip install dash-auth-external ``` ## Simple Usage ``` -auth = DashAuthExternal() - - -server = +#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) +``` +We then pass the flask server from this object to dash on init. +``` +app = Dash(__name__, server=server) +``` +That's it! You can now define your layout and callbacks as usual. +> To obtain your access token, call the get_token method of your Auth object. +> **NOTE** This can **ONLY** be done in the context of a dash callback. +``` +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 +``` -```