Skip to main content

Azure TokenCredential that fetches Fabric tokens from vd-studio's local OAuth endpoint, for use with dbt-fabricspark's token_credential auth method.

Project description

vdstudio-dbtfabriclake-cred

An Azure TokenCredential that fetches Microsoft Fabric access tokens from a running vd-studio instance, for use with dbt-fabricspark's token_credential authentication method.

What it does

vd-studio runs a local HTTP server that handles OAuth refresh against Microsoft Fabric. This package exposes a small TokenCredential implementation that calls that server with a configured user id and returns a fresh access token on every request. Plug it into dbt-fabricspark's token_credential auth path and dbt calls flow through vd-studio's OAuth.

Install

pip install vdstudio-dbtfabriclake-cred

Use

In profiles.yml:

my_profile:
  outputs:
    dev:
      type: fabricspark
      method: livy
      authentication: token_credential
      credential_class: "vdstudio_dbtfabriclake_cred.VDStudioFabricCredential"
      # Both kwargs are optional; if omitted, the class reads
      # VD_STUDIO_TOKEN_URL and VD_STUDIO_USER_ID from the environment.
      credential_kwargs:
        endpoint_url: "{{ env_var('VD_STUDIO_TOKEN_URL') }}"
        user_id: "{{ env_var('VD_STUDIO_USER_ID') }}"
      endpoint: https://api.fabric.microsoft.com/v1
      workspaceid: "<your-workspace-uuid>"
      lakehouseid: "<your-lakehouse-uuid>"
      lakehouse: "<your-lakehouse-name>"
      schema: "<your-schema>"

Environment variables

Variable Used as fallback for
VD_STUDIO_TOKEN_URL endpoint_url constructor kwarg
VD_STUDIO_USER_ID user_id constructor kwarg

If a kwarg is passed explicitly it wins; otherwise the env var is consulted. If neither is set, __init__ raises ValueError.

Endpoint contract

The package issues:

GET <endpoint_url>?scope=<scope>&user_id=<user_id>

with a 10-second default timeout. It expects a JSON response shaped like:

{
  "access_token": "eyJ...",
  "expires_in": 3600
}

Non-200 responses:

Status Behavior
401 RuntimeError("Token refresh failed. Please re-login in vd-studio.")
403 RuntimeError("Token endpoint rejected request. Must be called from localhost.")
other requests.HTTPError propagated from raise_for_status()

expires_in defaults to 3600 seconds when absent.

Development

pip install -e ".[dev]"
pytest

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vdstudio_dbtfabriclake_cred-0.1.0.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vdstudio_dbtfabriclake_cred-0.1.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file vdstudio_dbtfabriclake_cred-0.1.0.tar.gz.

File metadata

File hashes

Hashes for vdstudio_dbtfabriclake_cred-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1fa73e77bb570ccd7288ce9f8f6aa6c9deddb9bce66fe0f5aba92b6965151e63
MD5 e63da1a9a6717e9681edcf6e70f62077
BLAKE2b-256 920f1560cab7f70c1e6e8c12c872253185a0391ba37c7c8dd6d968a5ecb5b60a

See more details on using hashes here.

File details

Details for the file vdstudio_dbtfabriclake_cred-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vdstudio_dbtfabriclake_cred-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 298e66dfc9c0896116d2b5f3438b8c2e25ec2944677f063f52404e8e695e5455
MD5 5a6be80b5e57a92141f90a62ac57f212
BLAKE2b-256 505335a401656ec04c4ffd92d89756f559444f12f29caafd3866ec97a37dc010

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page