Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adamsilverstein/wp-api-js-oauth
https://github.com/adamsilverstein/wp-api-js-oauth
javascript oauth-client oauth1 rest-api wordpress wp-api
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/adamsilverstein/wp-api-js-oauth
- Owner: adamsilverstein
- Created: 2017-03-16T18:14:48.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-20T13:18:55.000Z (almost 8 years ago)
- Last Synced: 2024-12-16T14:04:40.934Z (11 days ago)
- Topics: javascript, oauth-client, oauth1, rest-api, wordpress, wp-api
- Language: JavaScript
- Size: 21.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## WP-API JS OAuth
## About
OAuth1 support for the wp-api.js JavaScript client.Requires WordPress 4.7.x.
Initial release. Development ongoing at https://github.com/adamsilverstein/wp-api-js-oauth.
## Use
*Install the [OAuth1 plugin](https://github.com/WP-API/OAuth1) on the site you want to access and generate an Application key.*Connect to the OAuth server:
```js
wp.oauth.connect(
clientKey, // The application client key.
clientSecret, // The application client secret.
'oauth1/request', // The site request endpoint.
'oauth1/authorize', // The site authorize endpoint.
'oauth1/access' // The site access endpoint.
);
```The client will redirect the user to the authorization page and return them to the current page with temporary authorization tokens.
The client will make a second request to retrieve the long term token and stores that token in the browsers localStorage.
The client will detect the presence of the authorization token and use it for all authenticated requests.
Currently there is no renewal mechanism for expired tokens.
### Provides:
```
wp.oauth.setup
wp.oauth.debug
wp.oauth.extractTokens
wp.oauth.connect
wp.oauth.getLongTermToken```
### Extends:
```
wp.api.WPApiBaseModel.prototype.sync
```### Example:
Check out this [demonstration widget plugin](https://github.com/adamsilverstein/wp-api-js-oauth-widget) to see the OAuth feature in action.