WordPress.com implicit OAuth2 client-side authorization module
npm install wpcom-oauth-corswpcom-oauth-cors
================
WordPress.com
implicit OAuth2
client-side authorization module.
The server-side (Node.js) counterpart to this module iswpcom-oauth.
``cli`
> npm install wpcom-oauth-cors
`js
var wpcomOAuth = require('wpcom-oauth-cors')('
// 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();
`
Create a wpcomOAuth instance giving client_id (String) and optional parameters object
params:
* redirectblog
* response_type
* scope
* state
*
This snippet will log a posts array from site with id 123456.
`js
var wpcom = require('wpcom');
var wpcomOAuth = require('wpcom-oauth-cors')('
// 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 );
});
});
`
* Compile testing js file
`cli`
> make test
* Go to test/ folder
* Run web server (using serve for instance)
* Open index.html` with a browser