|
172 | 172 | { |
173 | 173 | "cell_type": "code", |
174 | 174 | "execution_count": null, |
175 | | - "id": "29521d68", |
| 175 | + "id": "276520b0", |
176 | 176 | "metadata": {}, |
177 | 177 | "outputs": [], |
178 | 178 | "source": [ |
179 | 179 | "#| export\n", |
180 | 180 | "class Auth0AppClient(_AppClient):\n", |
181 | 181 | " \"A `WebApplicationClient` for Auth0 OAuth2\"\n", |
182 | | - " def __init__(self, domain, client_id, client_secret, code=None, scope=None, https=True, redirect_uri=\"\", **kwargs):\n", |
183 | | - " self.redirect_uri,self.https,self.domain = redirect_uri,https,domain\n", |
| 182 | + " def __init__(self, domain, client_id, client_secret, code=None, scope=None, redirect_uri=\"\", **kwargs):\n", |
| 183 | + " self.redirect_uri,self.domain = redirect_uri,domain\n", |
184 | 184 | " config = self._fetch_openid_config()\n", |
185 | 185 | " self.base_url,self.token_url,self.info_url = config[\"authorization_endpoint\"],config[\"token_endpoint\"],config[\"userinfo_endpoint\"]\n", |
186 | | - " super().__init__(client_id, client_secret, code=code, scope=scope, https=https, redirect_uri=redirect_uri, **kwargs)\n", |
| 186 | + " super().__init__(client_id, client_secret, code=code, scope=scope, redirect_uri=redirect_uri, **kwargs)\n", |
187 | 187 | "\n", |
188 | 188 | " def _fetch_openid_config(self):\n", |
189 | 189 | " r = httpx.get(f\"https://{self.domain}/.well-known/openid-configuration\")\n", |
190 | 190 | " r.raise_for_status()\n", |
191 | 191 | " return r.json()\n", |
192 | 192 | "\n", |
193 | | - " def redir_url(self, req): return redir_url(req, self.redirect_uri, \"https\" if self.https else \"http\")\n", |
194 | | - "\n", |
195 | 193 | " def login_link(self, req):\n", |
196 | | - " d = dict(response_type=\"code\", client_id=self.client_id, scope=self.scope, redirect_uri=self.redir_url(req))\n", |
| 194 | + " d = dict(response_type=\"code\", client_id=self.client_id, scope=self.scope, redirect_uri=redir_url(req, self.redirect_uri))\n", |
197 | 195 | " return f\"{self.base_url}?{urlencode(d)}\"" |
198 | 196 | ] |
199 | 197 | }, |
|
204 | 202 | "metadata": {}, |
205 | 203 | "outputs": [], |
206 | 204 | "source": [ |
207 | | - "cli = GoogleAppClient.from_file('/Users/jhoward/subs_aai/_nbs/oauth-test/client_secret.json')" |
| 205 | + "# cli = GoogleAppClient.from_file('/Users/jhoward/subs_aai/_nbs/oauth-test/client_secret.json')" |
208 | 206 | ] |
209 | 207 | }, |
210 | 208 | { |
|
297 | 295 | "#| export\n", |
298 | 296 | "def redir_url(request, redir_path, scheme=None):\n", |
299 | 297 | " \"Get the redir url for the host in `request`\"\n", |
300 | | - " scheme = 'http' if request.url.hostname == 'localhost' else 'https'\n", |
| 298 | + " scheme = 'http' if request.url.hostname in (\"localhost\", \"127.0.0.1\") else 'https'\n", |
301 | 299 | " return f\"{scheme}://{request.url.netloc}{redir_path}\"" |
302 | 300 | ] |
303 | 301 | }, |
|
0 commit comments