Socket
Socket
Sign inDemoInstall

wpcom-oauth-cors

Package Overview
Dependencies
2
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    wpcom-oauth-cors

WordPress.com implicit OAuth2 client-side authorization module


Version published
Weekly downloads
1.8K
decreased by-9.25%
Maintainers
4
Install size
184 kB
Created
Weekly downloads
 

Readme

Source

wpcom-oauth-cors

WordPress.com implicit OAuth2 client-side authorization module.

The server-side (Node.js) counterpart to this module is wpcom-oauth.

> npm install wpcom-oauth-cors

How to use

var wpcomOAuth = require('wpcom-oauth-cors')('<client-id>');

// get auth object
wpcomOAuth.get(function(auth){
  // Here, your token is available as auth.access_token
  // e.g.:
  // var wpcom = require('wpcom');
  // var wpc = wpcom(auth.access_token);
});

// clean stored token
wpcomOAuth.clean();

// get stored token
var auth = wpcomOAauth.token();

API

wpcomOAuth(client_id, params)

Create a wpcomOAuth instance giving client_id (String) and optional parameters object

params:

  • redirect
  • blog
  • response_type
  • scope
  • state

wpcomOAuth.get(fn)

wpcomOAuth.clean()

wpcomOAuth.request()

wpcomOAuth.reset()

wpcomOAuth.token()

Example

This snippet will log a posts array from site with id 123456.

var wpcom = require('wpcom');
var wpcomOAuth = require('wpcom-oauth-cors')('<client-id>');

// get auth object
wpcomOAuth.get(function(auth){
  // Here, your token is available as auth.access_token
  var wpc = wpcom( auth.access_token );
  var mySite = wpc.site( 123456 );
  mySite.postsList({ number: 50, fields: "author,URL,title,geo" }, function(err, list) {
	  console.log( list );
  });
});

Test

  • Compile testing js file
> make test
  • Go to test/ folder

  • Run web server (using serve for instance)

  • Open index.html with a browser

FAQs

Last updated on 25 Jul 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc