Skip to content

Commit d278784

Browse files
authored
Merge pull request #10 from Automattic/update/usage-instructions
Update usage instructions to be clearer on how to use the access token
2 parents 8c8f274 + 8badc6b commit d278784

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ var wpcomOAuth = require('wpcom-oauth-cors')('<client-id>');
1919

2020
// get auth object
2121
wpcomOAuth.get(function(auth){
22-
// your token is here auth.access_token!
22+
// Here, your token is available as auth.access_token
23+
// e.g.:
24+
// var wpcom = require('wpcom');
25+
// var wpc = wpcom(auth.access_token);
2326
});
2427

2528
// clean stored token
@@ -53,6 +56,27 @@ Create a wpcomOAuth instance giving `client_id` (String) and optional parameters
5356

5457
### wpcomOAuth.token()
5558

59+
60+
## Example
61+
62+
This snippet will log a posts array from site with id `123456`.
63+
64+
```js
65+
var wpcom = require('wpcom');
66+
var wpcomOAuth = require('wpcom-oauth-cors')('<client-id>');
67+
68+
// get auth object
69+
wpcomOAuth.get(function(auth){
70+
// Here, your token is available as auth.access_token
71+
var wpc = wpcom( auth.access_token );
72+
var mySite = wpc.site( 123456 );
73+
mySite.postsList({ number: 50, fields: "author,URL,title,geo" }, function(err, list) {
74+
console.log( list );
75+
});
76+
});
77+
78+
```
79+
5680
## Test
5781

5882
* Compile testing js file

0 commit comments

Comments
 (0)