Authentication improvements for testing your apps

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 password 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 global 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 password grant_type.

$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.


Comments

6 responses to “Authentication improvements for testing your apps”

  1. Aaron Douglas Avatar
    Aaron Douglas

    Reblogged this on The Dangling Pointer and commented:

    Developers interested in contributing to the WordPress mobile apps can now connect to WordPress.com with their own account. More details to follow on how to set up the individual projects.

  2. Thanks for sharing such a wonderful resource. I totally agree with your post that App testing ….

  3. Thanks for this post.

  4. create an application password how

    1. Hi there,

      You can create an application password here: https://wordpress.com/me/security/two-step (you’ll need to be logged into WordPress.com of course)

      1. @Joey Kudish Thanks and I apologise for the delay in responses. We just too busy this day in studio can even remember last I check my social media account. thanks for the reply I will check it out and give you feedbacks.