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 = '<client-id>'; // get auth objectwpcomOAuth; // clean stored tokenwpcomOAuth; // get stored tokenvar auth = wpcomOAauth;
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 = ;var wpcomOAuth = '<client-id>'; // get auth objectwpcomOAuth;
Test
- Compile testing js file
> make test
-
Go to
test/
folder -
Run web server (using
serve
for instance) -
Open
index.html
with a browser