We’ve just made it easier for developers to authenticate and test API calls with their own applications.
As the client owner, you can now authenticate with the
grant_type, allowing you to skip the authorization step of authenticating, and logging in with your WordPress.com username and password. You can also gain the
scope so that you no longer need to request authentication for each blog you wish to test your code with.
This is especially useful to contributors of the WordPress Android and iOS apps, which previously required special whitelisting on our part.
Here’s an example of how you can get started with using both these features:
Note that if you are using 2-step authentication (highly recommended) you will need to create an application password to be able to use the
$curl = curl_init( "https://public-api.wordpress.com/oauth2/token" ); curl_setopt( $curl, CURLOPT_POST, true ); curl_setopt( $curl, CURLOPT_POSTFIELDS, array( 'client_id' => your_client_id, 'client_secret' => your_client_secret_key, 'grant_type' => 'password' 'username' => your_wpcom_username, 'password' => your_wpcom_password, ) ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1); $auth = curl_exec( $curl ); $auth = json_decode($auth); $access_key = $auth->access_token;
As noted above, these are only available to you as the owner of the application, and not to any other user. This is meant for testing purposes only.
You can review existing authentication methods here.
If you have any questions, please drop them in the comments or use our contact form to reach us.