Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

WordPress.com Connect Node/Express.js Demo

This is a simple Node.js/Express.js example demonstrating how to implement WordPress.com Connect (OAuth2 authentication) in your application.

Prerequisites

Setup Instructions

  1. Clone this repository (if you haven't already):

    git clone https://github.com/Automattic/wpcom-connect-examples.git
    cd wpcom-connect-examples/express.js
  2. Register a new application at WordPress.com Developer Console:

    • Set the Redirect URL to: http://localhost:3000/connected
    • Note your Client ID and Client Secret.
  3. Configure your credentials:

    • Open config.js in this folder.
    • Replace the client_id, client_secret, login_url, and redirect_url values with those from your app's settings.
    • Adjust login_url and redirect_url if you use a different port or domain.
  4. Install dependencies:

    npm install
  5. Start the server:

    npm start
  6. Test the demo:

    • Open http://localhost:3000 in your browser.
    • Click the "Connect with WordPress.com" button.
    • Authorize the app and you should see a "Connected to WordPress.com!" message.

Notes

  • This demo is for educational purposes. In a real application, you should securely store the access token and handle errors appropriately.
  • If you change the port or domain, update login_url and redirect_url in config.js and in your WordPress.com app settings.
  • You can set a custom session secret by defining the SESSION_SECRET environment variable.
  • For more details, see the official documentation.