Repository navigation
oauth plugin
An OAuth plugin signs an account in by an authorization-code redirect with PKCE, by a device code, or both, and renews the token before it expires. It is the sibling of the sign-in plugin for providers whose tokens do not last.
| Scaffold | rdownloader plugin new --type oauth |
plugin_type |
oauth |
| World | oauth-plugin |
| Exports |
begin, poll, device-begin, device-poll, refresh
|
| Template | sdk/templates/oauth |
| Contract | Interface oauth |
-
You never see a credential. The tokens an exchange produces go back through
store-oauth-token; later requests reach them only as{{secret:<reference>}}. -
You do not choose where the person is sent. The address
beginreturns must lie on a domain the manifest declares; the host refuses anything else. -
You remember nothing. What has to survive from
begintopoll— the PKCE verifier — travels inflow-state, which the host stores verbatim and never shows.
The scaffold asks for net_http with the provider's authorization and token endpoints; that list
also bounds the sign-in page a person is sent to. credentials is granted by the type.
oauth_flows = ["redirect", "device"] at the top of manifest.toml — above the first [table]
header, or TOML makes it a key of that table — names the ways in the plugin serves. The host calls
only what it names; a manifest without it serves the redirect alone. [extension] claims names
the provider slug it signs in.
Ask for exactly what you use: the install preview shows every grant, and a component importing an interface its manifest does not grant cannot be instantiated. Every capability is listed under Capabilities.
The PKCE verifier and the state are built from host.random-bytes — 32 bytes of operating
system entropy each, drawn separately — and from nothing else. A value computed from the clock and
the account id can be recomputed by anybody holding those inputs. An empty answer from
host.random-bytes is a refusal: fail the sign-in on it.
Three rules the flow turns on:
- A provider that refuses ends the sign-in; one that cannot be reached must not.
- "Not confirmed yet" is waiting, neither of the above.
- Nothing a provider wrote is ever repeated verbatim.
plugin new reads its templates from sdk/templates, so run it from a checkout of the repository:
git clone https://github.com/degoya/rDownloader.git
cd rDownloader
rdownloader plugin new --type oauth --out ../myprovider
cd ../myproviderWithout an installation of rDownloader, the packaging tool rd-pack —
cargo build --profile release-test -p rd-pack in the checkout — takes the same arguments:
target/release-test/rd-pack plugin new --type oauth --out ../myprovider.
The directory name becomes the crate name and the plugin's slug (--name sets another). The
scaffold gets its own plugin id, its own copy of the contract in wit/rdownloader.wit and its own
Ed25519 key pair: plugin-signing.key, whose public half is already in manifest.toml. Keep that
file out of version control.
-
src/pkce.rswrites PKCE, SHA-256 and base64url out — a guest has no WASI to borrow them from. -
src/flow.rsreads the token answers. -
src/guest.rsholds both entrances andrefresh. Delete the entrance your provider does not offer, fromoauth_flowsand fromsrc/guest.rsalike. -
manifest.toml:oauth_flows,[capabilities.net_http] domains,[extension] claims. -
locales/en.json: the English text of every failure code you report.
Change description and author under [metadata], and read the comment at the top of
src/lib.rs: it states what the host promises this type.
cargo testThe unit tests need no WebAssembly toolchain: only src/guest.rs is wasm32-specific. Give every
answer of your provider you read a test of its own.
cargo build --release --target wasm32-unknown-unknown
wasm-tools component new target/wasm32-unknown-unknown/release/myprovider.wasm -o target/myprovider.wasmThis needs the wasm32-unknown-unknown target and wasm-tools 1.261.0, the version the bundled
plugins are made with: cargo build makes a core module that carries the world src/guest.rs
generates, and wasm-tools component new turns it into the component. The plugin is built
without WASI: a component importing anything outside rdownloader:plugin is refused — see
Building without WASI.
rdownloader plugin package --manifest manifest.toml \
--component target/myprovider.wasm \
--locales locales --key plugin-signing.key --output myprovider.rdplug
rdownloader plugin conformance myprovider.rdplug --jsonconformance answers whether this application would run the package; it has to be clean before
you publish. For a key that outlives the scaffold, rdownloader plugin keygen --role plugin --output ./keys writes a pair: the Base64 in the .pub file goes into public_key, and key_id
gets a name of your own. In CI, RDOWNLOADER_PLUGIN_SIGNING_KEY holding the private key's PEM
text replaces --key. Details:
Packaging, signing and distribution.
For a first try without signing, package with --development instead of --key and start
rdownloader serve --plugin-development-mode, the only mode that accepts an unsigned package.
Install a signed package under Settings → Plugins → Add as an upload, or with
rdownloader plugin install myprovider.rdplug --root data/plugins. Review before installing shows
every permission and the signing key; a key this installation has not seen asks to be trusted —
compare its fingerprint. The message after installing says whether the plugin runs at once or
after the next restart; see Installing and trust.
The account form of the provider named in claims, under Settings → Accounts, offers the
sign-in; the renewal runs by itself before the token expires.
Publish the .rdplug together with your key's fingerprint, or — so that people get your new
versions in the Catalogue — in a plugin repository of your own: a signed index built with
rdownloader plugin index build and a repository-role key. A repository only delivers: every
package in it still needs your plugin key, approved by the person installing it. See
A repository index and
Running a plugin repository.
The SDK's reusable CI workflow,
sdk/ci/plugin.yml, builds,
checks the imports, packages and runs conformance on every push and pull request; it signs only
on a push to the default branch or a tag, so a pull request never sees the key.
- OAuth providers in the plugin reference — what the host does with each call, in full
-
Interface
oauth— every function and type, generated from the contract - Developing a plugin — the tools, translations, errors and what every type shares
-
The
oauthtemplate on GitHub
Getting started
- Installation
- Building from source
- Translating rDownloader
- First run
- Your first download
- The interface
Using rDownloader
- The download queue
- Download history
- The LinkGrabber
- Site rules
- Hosters and accounts
- Usenet and NZB
- BitTorrent
- Video and audio downloads
- Image galleries
- Livestream recording
- FTP, SFTP and WebDAV
- Object storage
- Subscriptions
- Remote jobs
- Storage, categories and rules
- Watched folders
- Post-processing
- Bandwidth and power
- Notifications
- Automation
- Statistics
- Keyboard and accessibility
Integrations
- Browser extension
- Desktop capture agent
- Command line client
- REST API
- MCP server
- Automation tool compatibility
Operating
- Docker and NAS
- Synology NAS
- Reverse proxy
- Accounts, sessions and permissions
- Sign in with an identity provider
- External tools
- Backup and restore
- Updates
- Security and privacy
- Diagnostics and maintenance
- Troubleshooting
- Defaults and limits
- Support matrix
Plugins
Plugin development
- Developing a plugin
- Resolver
- Transfer backend
- Intake parser
- Intake parser with mirrors
- Folder crawler
- Remote job
- Sign-in
- OAuth sign-in
- Metadata enricher
- Notification destination
- Post-processing step
- Upload destination
- Stream transform
- Plugin reference
- Packaging, signing and distribution
- Running a plugin repository
Reference