diff --git a/util/oauth.py b/util/oauth.py index 29c462bd2..f654098b9 100644 --- a/util/oauth.py +++ b/util/oauth.py @@ -3,7 +3,7 @@ import urlparse class OAuthConfig(object): def __init__(self, app, key_name): self.key_name = key_name - self.config = app.config.get(key_name, {}) + self.config = app.config.get(key_name) or {} def service_name(self): raise NotImplementedError @@ -24,9 +24,6 @@ class OAuthConfig(object): return self.config.get('CLIENT_SECRET') def _get_url(self, endpoint, *args): - if not endpoint: - raise Exception('Missing endpoint configuration for OAuth config %s', self.key_name) - for arg in args: endpoint = urlparse.urljoin(endpoint, arg) @@ -41,15 +38,15 @@ class GithubOAuthConfig(OAuthConfig): return 'GitHub' def authorize_endpoint(self): - endpoint = self.config.get('GITHUB_ENDPOINT') + endpoint = self.config.get('GITHUB_ENDPOINT', 'https://github.com') return self._get_url(endpoint, '/login/oauth/authorize') + '?' def token_endpoint(self): - endpoint = self.config.get('GITHUB_ENDPOINT') + endpoint = self.config.get('GITHUB_ENDPOINT', 'https://github.com') return self._get_url(endpoint, '/login/oauth/access_token') def _api_endpoint(self): - endpoint = self.config.get('GITHUB_ENDPOINT') + endpoint = self.config.get('GITHUB_ENDPOINT', 'https://github.com') return self.config.get('API_ENDPOINT', self._get_url(endpoint, '/api/v3/')) def user_endpoint(self):