Skip to content

Commit

Permalink
make rest api example pipeline also work without a token
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-rp committed Sep 4, 2024
1 parent f538059 commit fc21cac
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions dlt/sources/rest_api_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Optional

import dlt
from dlt.common.pendulum import pendulum
Expand All @@ -11,16 +11,21 @@


@dlt.source(name="github")
def github_source(access_token: str = dlt.secrets.value) -> Any:
def github_source(access_token: Optional[str] = dlt.secrets.value) -> Any:
# Create a REST API configuration for the GitHub API
# Use RESTAPIConfig to get autocompletion and type checking
config: RESTAPIConfig = {
"client": {
"base_url": "https://api.github.com/repos/dlt-hub/dlt/",
# "auth": {
# "type": "bearer",
# "token": access_token,
# },
# we add an auth config if the auth token is present
"auth": (
{
"type": "bearer",
"token": access_token,
}
if access_token
else None
),
},
# The default configuration for all resources and their endpoints
"resource_defaults": {
Expand Down

0 comments on commit fc21cac

Please sign in to comment.