createOAuthTokenSecretSource
function createOAuthTokenSecretSource(refresh: OAuthRefreshCallback, options?: OAuthTokenSecretSourceOptions): SecretProvider;Defined in: src/profiles/OAuthTokenSource.ts:71
Builds a SecretProvider that exchanges a refresh callback for cached, auto-renewing access tokens.
The returned function can be passed directly as profile.password for any
provider that accepts bearer tokens (Dropbox, Google Drive, OneDrive, GCS,
Azure Blob via AAD).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
refresh | OAuthRefreshCallback |
options | OAuthTokenSecretSourceOptions |
Returns
Section titled “Returns”Example
Section titled “Example”const password = createOAuthTokenSecretSource(async () => { const res = await fetch("https://example.com/oauth/token", { ... }); const body = (await res.json()) as { access_token: string; expires_in: number }; return { accessToken: body.access_token, expiresInSeconds: body.expires_in };});const session = await factory.create().connect({ host: "", protocol: "ftp", password });