Skip to content

✨ Source Microsoft Sharepoint: Make refresh token optional #37372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ data:
connectorSubtype: file
connectorType: source
definitionId: 59353119-f0f2-4e5a-a8ba-15d887bc34f6
dockerImageTag: 0.2.2
dockerImageTag: 0.2.3
dockerRepository: airbyte/source-microsoft-sharepoint
githubIssueLabel: source-microsoft-sharepoint
icon: microsoft-sharepoint.svg
Expand Down
925 changes: 499 additions & 426 deletions airbyte-integrations/connectors/source-microsoft-sharepoint/poetry.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
version = "0.2.2"
version = "0.2.3"
name = "source-microsoft-sharepoint"
description = "Source implementation for Microsoft SharePoint."
authors = [ "Airbyte <[email protected]>",]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Config:
description="Client Secret of your Microsoft developer application",
airbyte_secret=True,
)
refresh_token: str = Field(
refresh_token: Optional[str] = Field(
title="Refresh Token",
description="Refresh Token of your Microsoft developer application",
airbyte_secret=True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,18 @@ def drives(self):
"""
drives = execute_query_with_retry(self.one_drive_client.drives.get())

if self.config.credentials.auth_type == "Client":
my_drive = execute_query_with_retry(self.one_drive_client.me.drive.get())
else:
my_drive = execute_query_with_retry(
self.one_drive_client.users.get_by_principal_name(self.config.credentials.user_principal_name).drive.get()
)
# skip this step for application authentication flow
if self.config.credentials.auth_type != "Client" or (
hasattr(self.config.credentials, "refresh_token") and self.config.credentials.refresh_token
):
if self.config.credentials.auth_type == "Client":
my_drive = execute_query_with_retry(self.one_drive_client.me.drive.get())
else:
my_drive = execute_query_with_retry(
self.one_drive_client.users.get_by_principal_name(self.config.credentials.user_principal_name).drive.get()
)

drives.add_child(my_drive)
drives.add_child(my_drive)

return drives

Expand All @@ -226,11 +230,15 @@ def get_all_files(self):
# Get files from accessible drives
yield from self._get_files_by_drive_name(self.drives, self.config.folder_path)

if self.config.search_scope in ("SHARED_ITEMS", "ALL"):
parsed_drives = [] if self.config.search_scope == "SHARED_ITEMS" else self.drives
# skip this step for application authentication flow
if self.config.credentials.auth_type != "Client" or (
hasattr(self.config.credentials, "refresh_token") and self.config.credentials.refresh_token
):
if self.config.search_scope in ("SHARED_ITEMS", "ALL"):
parsed_drives = [] if self.config.search_scope == "SHARED_ITEMS" else self.drives

# Get files from shared items
yield from self._get_shared_files_from_all_drives(parsed_drives)
# Get files from shared items
yield from self._get_shared_files_from_all_drives(parsed_drives)

def get_matching_files(self, globs: List[str], prefix: Optional[str], logger: logging.Logger) -> Iterable[RemoteFile]:
"""
Expand Down
13 changes: 7 additions & 6 deletions docs/integrations/sources/microsoft-sharepoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ The connector is restricted by normal Microsoft Graph [requests limitation](http

## Changelog

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:--------------------------|
| 0.2.2 | 2024-03-28 | [36573](https://github.com/airbytehq/airbyte/pull/36573) | Update QL to 400 |
| 0.2.1 | 2024-03-22 | [36381](https://github.com/airbytehq/airbyte/pull/36381) | Unpin CDK |
| 0.2.0 | 2024-03-06 | [35830](https://github.com/airbytehq/airbyte/pull/35830) | Add fetching shared items |
| 0.1.0 | 2024-01-25 | [33537](https://github.com/airbytehq/airbyte/pull/33537) | New source |
| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:----------------------------|
| 0.2.3 | 2024-04-17 | [37372](https://github.com/airbytehq/airbyte/pull/37372) | Make refresh token optional |
| 0.2.2 | 2024-03-28 | [36573](https://github.com/airbytehq/airbyte/pull/36573) | Update QL to 400 |
| 0.2.1 | 2024-03-22 | [36381](https://github.com/airbytehq/airbyte/pull/36381) | Unpin CDK |
| 0.2.0 | 2024-03-06 | [35830](https://github.com/airbytehq/airbyte/pull/35830) | Add fetching shared items |
| 0.1.0 | 2024-01-25 | [33537](https://github.com/airbytehq/airbyte/pull/33537) | New source |

</HideInUI>
Loading