Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesholcombe authored Jan 7, 2022
1 parent d242a46 commit 7e8ae26
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```



```



Expand Down

0 comments on commit 7e8ae26

Please sign in to comment.