Decouple oauth methods from app with a namedtuple

This commit is contained in:
Sam Chow 2018-05-25 13:49:36 -04:00
parent d45b925155
commit e967fde3ae
7 changed files with 20 additions and 7 deletions

View file

@ -29,13 +29,13 @@ class GitLabOAuthService(OAuthService):
def token_endpoint(self):
return OAuthEndpoint(slash_join(self._endpoint(), '/oauth/token'))
def validate_client_id_and_secret(self, http_client, app_config):
def validate_client_id_and_secret(self, http_client, url_scheme_and_hostname):
# We validate the client ID and secret by hitting the OAuth token exchange endpoint with
# the real client ID and secret, but a fake auth code to exchange. Gitlab's implementation will
# return `invalid_client` as the `error` if the client ID or secret is invalid; otherwise, it
# will return another error.
url = self.token_endpoint().to_url()
redirect_uri = self.get_redirect_uri(app_config, redirect_suffix='trigger')
redirect_uri = self.get_redirect_uri(url_scheme_and_hostname, redirect_suffix='trigger')
data = {
'code': 'fakecode',
'client_id': self.client_id(),