| 26 | |
| 27 | class Endpoint(view_base.BaseHandler): |
| 28 | def github_client(self): |
| 29 | client_key = 'github_client' |
| 30 | if '.appspot.com' not in self.request.host and \ |
| 31 | not self.request.host.startswith('localhost:'): |
| 32 | client_key = 'github_client_' + self.request.host |
| 33 | if not self.app.config.get(client_key): |
| 34 | try: |
| 35 | self.app.config[client_key] = secrets.get(client_key) |
| 36 | except KeyError: |
| 37 | self.abort(500, |
| 38 | body_template=( |
| 39 | 'An admin must <a href="/config">' |
| 40 | 'configure GitHub secrets</a> for %r first.' |
| 41 | % self.request.host)) |
| 42 | client = self.app.config[client_key] |
| 43 | return client['id'], client['secret'] |
| 44 | |
| 45 | def maybe_redirect(self, target): |
| 46 | """ |