PayPal Access 4 Node.js
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
node_modules
public
views
README.md
app.js
package.json

README.md

PayPal Access for node.js

This example shows how to integrate PayPal's open identity solution PayPal Access into an existing node.js that leverages the web framework Express.js & the templating engine Jade.

PayPal offers two flows right now - OpenID Connect & OAuth 2.0. This example leverages OpenID Connect to provide session management functionality.

This is intended as an orientation / helper to integrate PayPal Access in other projects.

How it works

Basically the file app.js creates a webserver which provides six different endpoints:

  • / - this is just a plain index site that provides a button for the actual login
  • /auth - this endpoint redirects the user to PayPal and enables him to login
  • /authz - this is the callback url that will be used by PayPal to deliver the requested authorization token
  • /refresh - the current tokens can be refreshed here
  • /validate - use this url to check the validity of your tokens
  • /logout - used to end the current session

PayPal's endpoints

PayPal offers five different endpoints for the OpenID Connect flow which provide different functionality:

These endpoints use the same base url: https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/..

Usage

To use the different endpoints the helper already provides five methods:

  • authorize
  • getProfile
  • validateToken
  • refreshToken
  • logout

To use these methods you'll have to pass the response and a callback-function like this:

getProfile(res, function(status, body) {
  console.log('status: ' + status);
});

Author

Tim Messerschmidt - PayPal Developer Evangelist - tmesserschmidt@paypal.com