Skip to content

Commit

Permalink
add draft for adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
leafty committed Jun 10, 2024
1 parent 8d986a6 commit 9ff3e8a
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,35 @@ def api_validate_account_response(self, response: Response) -> models.ConnectedA
return external_models.GitHubConnectedAccount.model_validate(response.json()).to_connected_account()


class BitBucketAdapter(ProviderAdapter):
"""Adapter for BitBucket OAuth2 clients."""

@property
def authorization_url(self) -> str:
"""The authorization URL for the OAuth2 protocol."""
return urljoin(self.client_url, "site/oauth2/authorize")

@property
def token_endpoint_url(self) -> str:
"""The token endpoint URL for the OAuth2 protocol."""
return urljoin(self.client_url, "site/oauth2/access_token")

@property
def api_url(self) -> str:
"""The URL used for API calls on the Resource Server."""
url = urlparse(self.client_url)
url = url._replace(netloc=f"api.{url.netloc}")
return urljoin(urlunparse(url), "2.0")

def api_validate_account_response(self, response: Response) -> models.ConnectedAccount:
"""Validates and returns the connected account response from the Resource Server."""
raise NotImplementedError()


_adapter_map: dict[ProviderKind, type[ProviderAdapter]] = {
ProviderKind.gitlab: GitLabAdapter,
ProviderKind.github: GitHubAdapter,
ProviderKind.bitbucket: BitBucketAdapter,
}


Expand Down

0 comments on commit 9ff3e8a

Please sign in to comment.