Skip to content

PCWProps/wpcom-rest-api-examples

 
 

Repository files navigation

WordPress.com REST API Example Projects

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.

Overview

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.

Getting Started

  1. Log in to WordPress.com
  2. Create a new WPCC application:
    Go to developer.wordpress.com/apps/ and register your app. You can update these settings at any time.
  3. Configure your example:
    Update the relevant config file in your chosen example with your:
    • Client ID
    • Client Secret
    • Login URL
    • Redirect URL
  4. Run the example:
    • Follow the instructions of each example's README
  5. Log in and test authentication!

Example Projects

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

Contributing

If you implement a demo for a framework not listed here, we'd love to include it! Please submit a pull request.

Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 52.6%
  • PHP 21.5%
  • CSS 17.3%
  • Pug 6.4%
  • HTML 2.2%