Function: getUsernameWithApiLookup()
Function: getUsernameWithApiLookup()
function getUsernameWithApiLookup(config?: Partial<LakebasePoolConfig>): Promise<string | undefined>;Resolves the PostgreSQL username for a Lakebase connection.
Extends getUsernameSync with an async fallback that fetches the current user's identity from the Databricks workspace API. Use this when you don't have an explicit username configured and want automatic resolution (e.g. human users authenticating via PAT or browser OAuth in ~/.databrickscfg).
Resolution priority:
config.user— explicit config valuePGUSERenv varDATABRICKS_CLIENT_IDenv var (service principals)currentUser.me()— fetched from Databricks workspace API
Returns undefined if all attempts fail rather than throwing, so the
caller can decide whether to proceed or surface an error.
Parameters
| Parameter | Type |
|---|---|
config? | Partial<LakebasePoolConfig> |
Returns
Promise<string | undefined>