OAuth 2.0: Benefits and use cases — why?

Could anyone explain what’s good about OAuth2 and why we should implement it? I ask because I’m a bit confused about it — here’s my current thoughts: OAuth1 (more precisely HMAC) requests seem logical, easy to understand, easy to develop and really, really secure. OAuth2, instead, brings authorization requests, access tokens and refresh tokens, and … Read more

$_SESSION variables lost during OAuth callback

When I attempt an OAuth handshake, the first step is a GET call to obtain an access code like so. # Redirect to request authorization code $url = $this->get_authorization_url(); header(“Location: $url”); exit; Just before I send this I store the current URL in a $_SESSION[‘last_url’] variable so that after authentication is complete I can redirect … Read more

Facebook OAuth “The domain of this URL isn’t included in the app’s domain”

Let me first start with saying I’ve searched for an answer to this question for quite some time… I’m trying to setup Facebook OAuth to work with my application that is being developed locally on my machine. Everything was working perfect with Facebook authorization UNTIL I moved from using localhost to another domain name (still … Read more

How to build a plugin that supports authenticated POST requests to the REST API from external servers?

One of the main purposes of an API is to allow the integration of different services/systems. Let’s consider that the WordPress REST API can have both public and protected endpoints, where public endpoints do not require any form of authentication, and protected endpoints do. Example of a public endpoint: GET https://main.loc/wp-json/wp/v2/posts Example of a protected … Read more

Why is there an “Authorization Code” flow in OAuth2 when “Implicit” flow works so well?

With the “Implicit” flow the client (likely a browser) will get a access token, after the Resource Owner (i.e. the user) gave access. With the “Authorization Code” flow however, the client (usually a web server) does only get an authorization code after the Resource Owner (i.e. the user) gave access. With that authorization code the … Read more

How do I use the WP REST API plugin and the OAuth Server plugin to allow for registration and login?

Are there any example projects that do the same? I want to be able to login and register for accounts on my site via the API. 2 Answers 2 I know it’s a bit far fetched, but might help. For anyone looking for WP REST API implementation with JWT, here’s our solution. Add it to … Read more