How to Use OAuth in WordPress: A Practical 2026 Guide
OAuth is the system behind every “Sign in with your account” button on the web. It lets one site trust another without sharing a password. If you want that kind of login on your own site, or you need an app to talk to your site safely, OAuth is the tool for the job. WordPress can use it, but not straight out of the box. This 2026 guide explains what OAuth is, how it fits with WordPress, how to set it up step by step, and how to fix the errors people hit most.
What OAuth Is, in Plain Words
OAuth is an open standard for granting access. The current version is OAuth 2.0. Think of a hotel key card. The front desk checks who you are, then hands you a card that opens one room for a few days. You never get the master key. OAuth works the same way. A trusted service checks the user, then hands your site a short-lived token in place of a password.
Four parts are involved, and the terms come up in every setup screen. The user owns the account. The client is the app that wants access. The authorization server checks the user and issues tokens. The resource server holds the data and accepts those tokens. Two more words matter. A scope is the list of things a token may do, such as “read email address”. A redirect URI is the exact web address the user is sent back to after they approve.
One point confuses many people. OAuth by itself grants access. It does not prove who someone is. A layer on top, named OpenID Connect, adds the identity part. Most “sign in with” buttons use both together. To see where this sits beside the other login methods, read our guide on what authentication WordPress uses.
Does WordPress Support OAuth Out of the Box?
The short answer is no. WordPress core has no OAuth feature that you can switch on. A fresh install signs users in with a username, a password and a browser cookie. For apps and scripts, core offers Application Passwords, which arrived in version 5.6. Both methods work well, but neither one is OAuth.
This was a choice, not an oversight. OAuth needs settings that differ for each provider. It also needs careful storage of secret keys. The core team left that work to plugins, so each site can add only what it needs. In practice, this means every OAuth setup in WordPress has two halves. One half is a plugin on your site. The other half is an app record that you create with the outside provider.
You can check what your site offers today in a minute. Go to Users → Profile and scroll down. If you see a section named Application Passwords, the built-in method is on. Then open Plugins → Installed Plugins and look for any login, single sign-on or API plugin. If none is listed, your site has no OAuth support yet. That is normal, and the next sections show how to add it.
Three Ways to Use OAuth on a WordPress Site
“Use OAuth in WordPress” can mean three different jobs. Each one needs a different kind of plugin, so decide which you need before you install a thing. Picking the wrong type is the most common false start.
1. Let people sign in with an outside account. Here your site is the client. A visitor clicks a button, signs in with their email, social or company account, and lands back on your site as a logged-in user. This is often named social login or single sign-on. It suits member sites, stores and company intranets.
2. Let apps sign in to your site. Here your site is the authorization server. A mobile app or a second website asks your WordPress site for a token, then uses it to read or write data. You need an OAuth server plugin for this. It suits custom apps and headless builds.
3. Link your site to an outside service. Many plugins show a “Connect” button for mail, analytics or storage. Behind that button is an OAuth flow. You approve access once, and the plugin stores a token. Sending site email this way is safer than saving a mailbox password in your settings.
The setup steps below follow the first job, since it is the one most site owners ask about. The same ideas, such as keys, scopes and redirect addresses, carry over to the other two.
How to Set Up OAuth Login Step by Step
Before you start, take a full backup and try this on a staging copy first. A login change that goes wrong can lock you out. Our guide on how to set up a staging site in WordPress shows how. Your site must also run on HTTPS, since providers refuse plain HTTP addresses.
Step 1: Install a login plugin that supports OAuth 2.0. Go to Plugins → Add New Plugin. Pick one that is updated often and works with your version of WordPress. Activate it and open its settings page.
Step 2: Copy the redirect URI. The plugin shows a callback address, often ending in a path the plugin adds. Copy it exactly. A missing slash is enough to break the flow.
Step 3: Create an app with the provider. Sign in to the provider’s developer console and register a new web app. Paste the redirect URI into the allowed list. Choose the smallest scopes that work. For login, that is most often openid, email and profile.
Step 4: Copy the client ID and client secret. The provider gives you two values. The ID is public. The secret is not, so treat it like a password. Paste both into the plugin settings and save.
Step 5: Set the user rules. Decide what happens when a new person signs in. Set the default role to Subscriber. Never let the plugin create Administrator accounts by itself.
Step 6: Test in a private window. Click the new button on /wp-login.php, approve the request, and confirm you land back on your site logged in. Keep your normal admin session open in another window until the test passes.
How to Use OAuth With the WordPress REST API
The REST API lets outside code read and change your site through web addresses that start with /wp-json/. Public data, such as published posts, needs no login. Anything private does. With an OAuth server plugin in place, an app can prove itself with a token and not with a user’s password.
The flow has three stages. First, the app sends the user to an authorize address on your site. The user logs in to WordPress and clicks to approve. Second, your site sends the user back to the app with a one-time code. The app swaps that code for an access token at a token address. Third, the app adds the token to each request in a header:
Authorization: Bearer YOUR_ACCESS_TOKEN
WordPress reads the header, finds the linked user, and applies that user’s role. An Editor’s token can edit posts. A Subscriber’s token cannot. Tokens expire, often within an hour. The app then uses a longer-lived refresh token to get a new one, so the user is not asked again.
For apps that run on a phone or in a browser, use the authorization code flow with PKCE. That is an extra check that stops a stolen code from being reused. Avoid the older “implicit” flow. It is now seen as legacy and has been replaced by PKCE. If the API is new to you, start with our guide on what the WordPress REST API is.
OAuth or Application Passwords: Which Should You Use?
Many people reach for OAuth when a simpler tool would do. WordPress has a built-in option for API access named Application Passwords. You make one under Users → Profile → Application Passwords. Type a name, click Add New Application Password, and copy the 24-character code. Your script then sends it with your username over HTTPS. No plugin is needed.
Use an Application Password when you control both ends. A backup script, a reporting tool or a one-off import are good cases. Each password can be revoked by itself, and it never works on the normal login screen. The weak points are that it does not expire and it carries the full rights of the user who made it. Create it under a user with the lowest role that can do the job.
Use OAuth when other people are involved. If outside users must approve access, if you want tokens that expire, or if you need narrow scopes, OAuth is the better fit. It is also the right choice when your staff should sign in with one company account across many tools. The cost is more setup and one more plugin to keep updated. Our guide on what WordPress Application Passwords are covers the built-in route in full.
Common OAuth Errors in WordPress and What They Mean
OAuth errors look cryptic, but each one points to a clear cause. Most trace back to a value that does not match on both sides. Check these before you swap plugins.
redirect_uri_mismatch. The callback address in the provider’s console differs from the one your site sent. Compare them character by character. Look for http versus https, www versus none, and a trailing slash.
invalid_client. The client ID or secret is wrong. A stray space from a copy and paste is the usual cause. Paste both again, or make a new secret.
invalid_grant. The one-time code was used twice or timed out. A page cache that stores the callback page can cause this. Exclude the login and callback addresses from your cache.
The token is sent but WordPress says “not logged in”. Some server setups strip the Authorization header before PHP sees it. Your host can confirm this. The fix is a one-line rule in the .htaccess file in your site’s main folder. Take a backup of that file before any edit, since a typo there can take the whole site offline.
Users land on a blank or looping page. A security plugin or a custom login address may block the callback. Turn such rules off on your staging copy, one at a time, to find the one in the way.
How to Keep an OAuth Setup Secure
OAuth removes passwords from the flow, but it adds keys and tokens that need the same care. A leaked client secret lets a stranger pose as your site. A few habits keep the risk low, and none of them needs code.
Store the client secret with care. Some plugins let you define it in wp-config.php so it stays out of the database. Back up that file before you edit it. Ask for the fewest scopes you can. Review the list of allowed redirect addresses and delete old ones, such as a staging address you no longer use. Change the secret at once if a developer who knew it leaves your team.
Keep a way back in. Leave one admin account with a strong password and two-factor login, in case the provider has an outage. Our guide on how to add 2FA to the WordPress admin login covers that step. Update the OAuth plugin as soon as fixes come out, and remove it fully if you stop using it.
If you would like help with the plan or the setup of OAuth on your site, the team at 24×7 WP Support works on WordPress login and API setups every day. Get in touch and we can take a look at what your site needs.
Related posts:

Brian is a WordPress support specialist and content contributor at 24×7 WP Support. He writes practical, easy-to-follow guides on WordPress troubleshooting, WooCommerce issues, plugin and theme errors, website security, migrations, performance optimization, and integrations. With a focus on solving real website problems, Brian helps business owners, bloggers, and online store managers keep their WordPress sites running smoothly.







