|
11 | 11 | AsyncFailureArgs, |
12 | 12 | ) |
13 | 13 | from slack_bolt.oauth.async_oauth_settings import AsyncOAuthSettings |
| 14 | +from slack_bolt.oauth.internals import _build_default_install_page_html |
14 | 15 | from slack_bolt.request.async_request import AsyncBoltRequest |
15 | 16 | from slack_bolt.response import BoltResponse |
16 | 17 | from slack_sdk.errors import SlackApiError |
@@ -151,26 +152,32 @@ def sqlite3( |
151 | 152 |
|
152 | 153 | async def handle_installation(self, request: AsyncBoltRequest) -> BoltResponse: |
153 | 154 | state = await self.issue_new_state(request) |
154 | | - return await self.build_authorize_url_redirection(request, state) |
| 155 | + url = await self.build_authorize_url(state, request) |
| 156 | + html = await self.build_install_page_html(url, request) |
| 157 | + set_cookie_value = self.settings.state_utils.build_set_cookie_for_new_state( |
| 158 | + state |
| 159 | + ) |
| 160 | + return BoltResponse( |
| 161 | + status=200, |
| 162 | + body=html, |
| 163 | + headers={ |
| 164 | + "Content-Type": "text/html; charset=utf-8", |
| 165 | + "Content-Length": len(bytes(html, "utf-8")), |
| 166 | + "Set-Cookie": [set_cookie_value], |
| 167 | + }, |
| 168 | + ) |
155 | 169 |
|
156 | 170 | # ---------------------- |
157 | 171 | # Internal methods for Installation |
158 | 172 |
|
159 | 173 | async def issue_new_state(self, request: AsyncBoltRequest) -> str: |
160 | 174 | return await self.settings.state_store.async_issue() |
161 | 175 |
|
162 | | - async def build_authorize_url_redirection( |
163 | | - self, request: AsyncBoltRequest, state: str |
164 | | - ) -> BoltResponse: |
165 | | - return BoltResponse( |
166 | | - status=302, |
167 | | - headers={ |
168 | | - "Location": [self.settings.authorize_url_generator.generate(state)], |
169 | | - "Set-Cookie": [ |
170 | | - self.settings.state_utils.build_set_cookie_for_new_state(state) |
171 | | - ], |
172 | | - }, |
173 | | - ) |
| 176 | + async def build_authorize_url(self, state: str, request: AsyncBoltRequest) -> str: |
| 177 | + return self.settings.authorize_url_generator.generate(state) |
| 178 | + |
| 179 | + async def build_install_page_html(self, url: str, request: AsyncBoltRequest) -> str: |
| 180 | + return _build_default_install_page_html(url) |
174 | 181 |
|
175 | 182 | # ----------------------------- |
176 | 183 | # Callback |
|
0 commit comments