@@ -34,6 +34,7 @@ The code snippet below demonstrates how to build it using `Flask <https://flask.
3434.. code-block :: python
3535
3636 import os
37+ import html
3738 from slack_sdk.oauth import AuthorizeUrlGenerator
3839 from slack_sdk.oauth.installation_store import FileInstallationStore, Installation
3940 from slack_sdk.oauth.state_store import FileOAuthStateStore
@@ -59,7 +60,7 @@ The code snippet below demonstrates how to build it using `Flask <https://flask.
5960 state = state_store.issue()
6061 # https://slack.com/oauth/v2/authorize?state=(generated value)&client_id={client_id}&scope=app_mentions:read,chat:write&user_scope=search:read
6162 url = authorize_url_generator.generate(state)
62- return f ' <a href=" { url} "> ' \
63+ return f ' <a href=" { html.escape( url) } "> ' \
6364 f ' <img alt=""Add to Slack"" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcset="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/[email protected] 2x" /></a> ' 6465
6566 When accessing ``https://(your domain)/slack/install ``, you will see "Add to Slack" button in the webpage. You can start the app's installation flow by clicking the button.
@@ -90,13 +91,11 @@ The redirection gives you a ``code`` parameter. You can exchange the value for a
9091 redirect_uri = redirect_uri,
9192 code = request.args[" code" ]
9293 )
93-
94- installed_enterprise = oauth_response.get(" enterprise" , {})
94+ installed_enterprise = oauth_response.get(" enterprise" ) or {}
9595 is_enterprise_install = oauth_response.get(" is_enterprise_install" )
96- installed_team = oauth_response.get(" team" , {})
97- installer = oauth_response.get(" authed_user" , {})
98- incoming_webhook = oauth_response.get(" incoming_webhook" , {})
99-
96+ installed_team = oauth_response.get(" team" ) or {}
97+ installer = oauth_response.get(" authed_user" ) or {}
98+ incoming_webhook = oauth_response.get(" incoming_webhook" ) or {}
10099 bot_token = oauth_response.get(" access_token" )
101100 # NOTE : oauth.v2.access doesn't include bot_id in response
102101 bot_id = None
@@ -137,7 +136,7 @@ The redirection gives you a ``code`` parameter. You can exchange the value for a
137136 return make_response(f " Try the installation again (the state value is already expired) " , 400 )
138137
139138 error = request.args[" error" ] if " error" in request.args else " "
140- return make_response(f " Something is wrong with the installation (error: { error} ) " , 400 )
139+ return make_response(f " Something is wrong with the installation (error: { html.escape( error) } ) " , 400 )
141140
142141 Token Lookup
143142*************************************************
0 commit comments