| 1 |
=== JSON API Auth === |
| 2 |
|
| 3 |
Donate link: http://www.parorrey.com |
| 4 |
|
| 5 |
Tags: json api, api, authenticate user, wordpress user authentication |
| 6 |
|
| 7 |
Contributors: parorrey |
| 8 |
|
| 9 |
Stable tag: 1.3 |
| 10 |
|
| 11 |
Requires at least: 3.0.1 |
| 12 |
|
| 13 |
Tested up to: 3.9.1 |
| 14 |
|
| 15 |
License: GPLv2 or later |
| 16 |
|
| 17 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html |
| 18 |
|
| 19 |
Extends the JSON API Plugin for RESTful user authentication |
| 20 |
|
| 21 |
==Description== |
| 22 |
|
| 23 |
JSON API Auth extends the JSON API Plugin to allow RESTful user authentication. |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
Features include: |
| 28 |
|
| 29 |
* Generate Auth Cookie for user authentication |
| 30 |
|
| 31 |
* Validate Auth Cookie |
| 32 |
|
| 33 |
* Clear Auth Cookie |
| 34 |
|
| 35 |
* Get Current User Info |
| 36 |
|
| 37 |
|
| 38 |
For details: http://www.parorrey.com/solutions/json-api-auth/ |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
==Installation== |
| 43 |
|
| 44 |
First you have to install the JSON API for WordPress Plugin (http://wordpress.org/extend/plugins/json-api/installation/). |
| 45 |
|
| 46 |
To install JSON API Auth just follow these steps: |
| 47 |
|
| 48 |
* upload the folder "json-api-auth" to your WordPress plugin folder (/wp-content/plugins) |
| 49 |
|
| 50 |
* activate the plugin through the 'Plugins' menu in WordPress or by using the link provided by the plugin installer |
| 51 |
|
| 52 |
* activate the controller through the JSON API menu found in the WordPress admin center (Settings -> JSON API) |
| 53 |
|
| 54 |
|
| 55 |
== Screenshots == |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
==Changelog== |
| 61 |
|
| 62 |
= 1.3 = |
| 63 |
|
| 64 |
* Removed bug for generating cookie |
| 65 |
|
| 66 |
|
| 67 |
= 1.2 = |
| 68 |
|
| 69 |
* Updated plugin description, documentation and few urls |
| 70 |
|
| 71 |
= 1.1 = |
| 72 |
|
| 73 |
* Added clear_auth_cookie() for removing auth cookie. |
| 74 |
|
| 75 |
* Added documentation for the available end points |
| 76 |
|
| 77 |
|
| 78 |
= 1.0 = |
| 79 |
|
| 80 |
* Added the user avatar info for generate_auth_cookie() and get_currentuserinfo() |
| 81 |
|
| 82 |
|
| 83 |
* Updated the FAQs |
| 84 |
|
| 85 |
= 0.1 = |
| 86 |
|
| 87 |
* Initial release. |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
== Upgrade Notice == |
| 92 |
|
| 93 |
= 0.1 = |
| 94 |
|
| 95 |
* Initial release. |
| 96 |
|
| 97 |
|
| 98 |
==Documentation== |
| 99 |
|
| 100 |
Thanks to 'mattberg' who wrote the auth controller (https://github.com/mattberg/wp-json-api-auth) initially. I have added few methods and authored it as a WordPress plugin so that it could easily be searched and installed vis WordPress. |
| 101 |
|
| 102 |
|
| 103 |
* There are following methods available: validate_auth_cookie, generate_auth_cookie, clear_auth_cookie, get_currentuserinfo |
| 104 |
|
| 105 |
* nonce can be created by calling http://localhost/api/get_nonce/?controller=auth&method=generate_auth_cookie |
| 106 |
|
| 107 |
* You can then use 'nonce' value to generate cookie. http://localhost/api/auth/generate_auth_cookie/?nonce=f4320f4a67&username=Catherine&password=password-here |
| 108 |
|
| 109 |
* Use cookie like this with your other controller calls: http://localhost/api/contoller-name/method-name/?cookie=Catherine|1392018917|3ad7b9f1c5c2cccb569c8a82119ca4fd |
| 110 |
|
| 111 |
For isntance, you have a new controller 'events' and want to allow users to post new 'event' using 'add_event' method. |
| 112 |
This is how you will call the end point with cookie and post the event with user info: |
| 113 |
|
| 114 |
http://localhost/api/events/add_event/?cookie=Catherine|1392018917|3ad7b9f1c5c2cccb569c8a82119ca4fd |
| 115 |
|
| 116 |
If you want sample code how it can be done, check 'JSON API User' plugin https://wordpress.org/plugins/json-api-user/. This Auth plugin is part of JSON API User plugin. |
| 117 |
|
| 118 |
= Method: validate_auth_cookie = |
| 119 |
|
| 120 |
It needs 'cookie' var. |
| 121 |
|
| 122 |
http://localhost/api/auth/validate_auth_cookie/?cookie=Catherine|1392018917|3ad7b9f1c5c2cccb569c8a82119ca4fd |
| 123 |
|
| 124 |
|
| 125 |
= Method: generate_auth_cookie = |
| 126 |
|
| 127 |
It needs 'nonce' var. |
| 128 |
|
| 129 |
First get the nonce: http://localhost/api/get_nonce/?controller=auth&method=generate_auth_cookie |
| 130 |
|
| 131 |
Then generate cookie: http://localhost/api/auth/generate_auth_cookie/?nonce=375034fjwfn39u8&user_id=john&password=PASSWORD-HERE |
| 132 |
|
| 133 |
|
| 134 |
= Method: clear_auth_cookie = |
| 135 |
|
| 136 |
It needs 'cookie' var. |
| 137 |
|
| 138 |
http://localhost/api/auth/validate_auth_cookie/?cookie=Catherine|1392018917|3ad7b9f1c5c2cccb569c8a82119ca4fd |
| 139 |
|
| 140 |
it will clear/expire any valid cookie that was earlier genereated using generate_auth_cookie end point |
| 141 |
|
| 142 |
|
| 143 |
= Method: get_currentuserinfo = |
| 144 |
|
| 145 |
It needs 'cookie' var. |
| 146 |
|
| 147 |
http://localhost/api/auth/get_currentuserinfo/?cookie=Catherine|1392018917|3ad7b9f1c5c2cccb569c8a82119ca4fd |