Skip to content
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

pass auth_config through to ContentFetcherTask #222

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Next Next commit
pass auth_config through to ContentFetcherTask
makes it possible to pass API headers to pystac_client
hrodmn committed Oct 28, 2022

Verified

This commit was signed with the committer’s verified signature.
limbonaut Serhii Snitsaruk
commit 2bffea6ce7fcbd1ed7c6830322301c8554c31848
4 changes: 4 additions & 0 deletions src/qgis_stac/api/base.py
Original file line number Diff line number Diff line change
@@ -119,6 +119,7 @@ def get_items(
api_capability=self.capability,
response_handler=self.handle_items,
error_handler=self.handle_error,
auth_config=self.auth_config,
)

QgsApplication.taskManager().addTask(self.content_task)
@@ -135,6 +136,7 @@ def get_collections(
resource_type=ResourceType.COLLECTION,
response_handler=self.handle_collections,
error_handler=self.handle_error,
auth_config=self.auth_config,
)

QgsApplication.taskManager().addTask(self.content_task)
@@ -156,6 +158,7 @@ def get_collection(
resource_type=ResourceType.COLLECTION,
response_handler=self.handle_collection,
error_handler=self.handle_error,
auth_config=self.auth_config,
)

QgsApplication.taskManager().addTask(self.content_task)
@@ -172,6 +175,7 @@ def get_conformance(
resource_type=ResourceType.CONFORMANCE,
response_handler=self.handle_conformance,
error_handler=self.handle_error,
auth_config=self.auth_config,
)

QgsApplication.taskManager().addTask(self.content_task)
12 changes: 11 additions & 1 deletion src/qgis_stac/api/network.py
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@

from qgis.core import (
QgsApplication,
QgsAuthMethodConfig,
QgsNetworkContentFetcherTask,
QgsTask,
)
@@ -80,6 +81,7 @@ def __init__(
api_capability: ApiCapability = None,
response_handler: typing.Callable = None,
error_handler: typing.Callable = None,
auth_config = None,
):
super().__init__()
self.url = url
@@ -88,6 +90,7 @@ def __init__(
self.api_capability = api_capability
self.response_handler = response_handler
self.error_handler = error_handler
self.auth_config = auth_config

def run(self):
"""
@@ -96,8 +99,15 @@ def run(self):
:returns: Whether the task completed successfully
:rtype: bool
"""
pystac_auth = {}
if self.auth_config:
auth_mgr = QgsApplication.authManager()
auth_cfg = QgsAuthMethodConfig()
auth_mgr.loadAuthenticationConfig(self.auth_config, auth_cfg, True)
if auth_cfg.method() == "APIHeader":
pystac_auth["headers"] = auth_cfg.configMap()
try:
self.client = Client.open(self.url)
self.client = Client.open(self.url, **pystac_auth)
if self.resource_type == \
ResourceType.FEATURE:
if self.search_params: