Repository navigation
Browser Sign In
Arun Prakash edited this page Oct 25, 2026
·
1 revision
The Application Passwords "authorize application" flow (WordPress 5.6+) lets the user approve your app on their own site. WordPress then redirects back with a freshly created application password, so your app never asks for or sees the account password.
await client.discover();
final flow = AppPasswordFlow.fromDiscovery(
client.discovery,
appName: 'My App',
successUrl: Uri.parse('myapp://wp-callback'), // https URL or a custom scheme your app handles
rejectUrl: Uri.parse('myapp://wp-rejected'),
);
await launchUrl(flow.authorizeUrl); // open the system browser (url_launcher)
// When the redirect arrives (app link / custom scheme handler):
switch (flow.parseCallback(callbackUri)) {
case final AppPasswordGranted granted:
client.reconfigure(
bootstrapper: (b) => b.withDefaultAuthorization(granted.toAuthorization()).build(),
);
// store granted.userLogin / granted.password in secure storage
case AppPasswordRejected():
print('The user declined');
}-
fromDiscoverythrows aStateErrorwhen the site does not advertise application passwords;AppPasswordFlow(authorizationEndpoint: ...)builds one by hand. - A random
stateis added to both redirect URLs and verified byparseCallback, which throws aFormatExceptionfor a callback that did not come from this flow or points to another site. -
appId(a UUID) groups the passwords of your app on the user's profile page. Pass a fixed one to keep it stable across installs. - WordPress only offers application passwords on HTTPS sites (and local development environments).
- Register a redirect target in your app: a custom URL scheme (
myapp://wp-callback), an Android App Link or an iOS Universal Link. PlainhttpsURLs work for web apps. - Create the flow from discovery (
client.discover()caches it) and openflow.authorizeUrlin the system browser. Do not use an embedded web view: the user must be able to trust the page. - On the redirect, hand the full URI to
flow.parseCallback. It returnsAppPasswordGranted(withuserLogin,password,siteUrl) orAppPasswordRejected. - Store the password in secure storage (Integration with Storage Packages) and configure the client with
granted.toAuthorization().
| Situation | What happens |
|---|---|
| Site has no application passwords (disabled, old WordPress, plugin) |
fromDiscovery throws a StateError. Check AppPasswordFlow.discoverEndpoint(discovery) != null first |
Callback with a wrong or missing state, or from another site |
parseCallback throws a FormatException
|
| User declines | AppPasswordRejected |
See Authorization for the other auth methods.
Getting started
- Usage
- Bootstrap and Configuration
- Authorization
- Browser Sign-In
- WordPress.com and Jetpack
- Multisite
- Supported REST Methods
Requests and data
- Sending Requests
- Error Handling and Responses
- Fluent Queries
- Interfaces and Extensions
- Custom Post Types
- Model Generator
- Meta and ACF
- Concurrent Edits
- Batch Requests
- Embed and Fields
- Pagination and Finders
- Parallel Requests
- Streaming and Polling
- Pattern Directory Items
Behaviour
- Retries
- Caching
- Request De-duplication and Concurrency
- Middlewares
- Logging
- Offline Write Queue
- Events and Statistics
Other APIs
Extend and test
Reference