This repository includes several example projects that demonstrate how to use OAuth to request explicit user permissions and perform authenticated operations on their behalf via token-secured endpoints, using a variety of popular languages and frameworks.
It also include examples of interacting with REST API endopints using Application Passwords.
Each example shows how to authenticate with WordPress.com, obtain an access token, and make authenticated requests to the WordPress.com REST API. These are intended as starting points for your own integrations.
- Log in to WordPress.com
- Create a new WPCC application:
Go to developer.wordpress.com/apps/ and register your app. You can update these settings at any time. - Configure your example:
Update the relevant config file in your chosen example with your:- Client ID
- Client Secret
- Login URL
- Redirect URL
- Run the example:
- Follow the instructions of each example's README
- Log in and test authentication!
Directory | Language | Framework | Description | Author |
---|---|---|---|---|
php-oauth-rest | PHP | N/A | Auth via wp.com, display user info and post publication | Automattic |
php-oauth-wpcom-connect | PHP | N/A | Auth via wp.com and display user info | Automattic |
node-wpcom-oauth | JavaScript | Node.js (Express) | Auth via wp.com, token display, user info and post publication - nice showcase if each step of iAuth workflow | Automattic |
react-express-oauth-rest | JavaScript | React + Express | Auth via wp.com, token display, and example REST API usage - use of client secret | Automattic |
react-implicit-oauth-rest | JavaScript | React (SPA) | Implicit flow auth via wp.com, token display, and example REST API usage - no use of client secret (implicit oAuth) | Automattic |
react-application-password | JavaScript | React (SPA) | Application Password to authenticate endpoints | Automattic |
If you implement a demo for a framework not listed here, we'd love to include it! Please submit a pull request.