Environment variables¶
This notebook reads its settings from environment variables. Set them before starting Jupyter:
GITHUB_ORG: GitHub organization or user that owns the repositoryGITHUB_REPO: repository nameGITHUB_USERNAME: your GitHub user nameGITHUB_TOKEN: a GitHub personal access token that can read the repository
Only Example 2 needs these; Example 1 reads a public repository anonymously.
Example 1¶
Unauthorized Access. Listing objects in a repo.
In [ ]:
Copied!
from fsspec import filesystem
# Example: https://github.com/fsspec/filesystem_spec
fs = filesystem("github", org="fsspec", repo="filesystem_spec")
fs.ls("")
from fsspec import filesystem
# Example: https://github.com/fsspec/filesystem_spec
fs = filesystem("github", org="fsspec", repo="filesystem_spec")
fs.ls("")
Example 2¶
Authorized access. Listing objects in a repo.
For authorised access, you must provide username and token, which can be made at https://github.com/settings/tokens
In [ ]:
Copied!
import os
from fsspec import filesystem
# Example: https://github.com/<org>/<repo>
fs = filesystem(
"github",
org=os.environ["GITHUB_ORG"],
repo=os.environ["GITHUB_REPO"],
username=os.environ["GITHUB_USERNAME"],
token=os.environ["GITHUB_TOKEN"],
)
fs.ls("")
import os
from fsspec import filesystem
# Example: https://github.com/<org>/<repo>
fs = filesystem(
"github",
org=os.environ["GITHUB_ORG"],
repo=os.environ["GITHUB_REPO"],
username=os.environ["GITHUB_USERNAME"],
token=os.environ["GITHUB_TOKEN"],
)
fs.ls("")