Title: Create post with access_token
Last modified: September 1, 2016

---

# Create post with access_token

 *  [rogeriopavan1984](https://wordpress.org/support/users/rogeriopavan1984/)
 * (@rogeriopavan1984)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/create-post-with-access_token/)
 * Hi, i get “access token” (wp_oauth plugin). How create post with REST API?
    url
   is “localhost:8080/blog/wp-json/wp/v2/posts”? how to make?
 *     ```
       $curl = curl_init( 'localhost:8080/blog/oauth/token' );
       curl_setopt( $curl, CURLOPT_POST, true );
       curl_setopt( $curl, CURLOPT_POSTFIELDS, array(
           'client_id' => 'GT9DiTPY6WNjGOp7aGvm6hsvCQ4xi4',
           'client_secret' => 'HTebdz1TV1KrGd0xQDUofe1JeusMEm',
           'grant_type' => 'password',
           'username' => 'rogerio_pavan',
           'password' => '270184',
       ) );
       curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1);
       $auth = curl_exec( $curl );
       print_r ($auth);
   
       $auth = json_decode($auth);
       $access_key = $auth->access_token;
       ```
   
 * [https://wordpress.org/plugins/rest-api/](https://wordpress.org/plugins/rest-api/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [rogeriopavan1984](https://wordpress.org/support/users/rogeriopavan1984/)
 * (@rogeriopavan1984)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/create-post-with-access_token/#post-7634780)
 * ok. I install “JSON Basic Authentication”. I created this code:
 *     ```
       $headers = array (
       	'Authorization' => 'Basic ' . base64_encode( 'rogerio_pavan' . ':' . '270184' ));
   
       $curl = curl_init();
       curl_setopt($curl, CURLOPT_URL, 'http://localhost:8080/blog/wp-json/wp/v2/posts');
       $data = array(
       	'title' => 'Hello World',
       	'content_raw'=>'no matters',
       	'date'=>'2016-08-01T14:00:00+10:00'
       );
   
       curl_setopt($curl, CURLOPT_POSTFIELDS, array(
           'method' => 'POST',
           'headers' => $headers,
           'body'    =>  $data));
   
       $post = curl_exec($curl );
       ```
   
 * and return `{"code":"rest_cannot_create","message":"Sorry, you are not allowed
   to create new posts.","data":{"status":401}}`

Viewing 1 replies (of 1 total)

The topic ‘Create post with access_token’ is closed to new replies.

 * ![](https://ps.w.org/rest-api/assets/icon-256x256.png?rev=1346297)
 * [WordPress REST API (Version 2)](https://wordpress.org/plugins/rest-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/rest-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/rest-api/)
 * [Active Topics](https://wordpress.org/support/plugin/rest-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/rest-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/rest-api/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [rogeriopavan1984](https://wordpress.org/support/users/rogeriopavan1984/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/create-post-with-access_token/#post-7634780)
 * Status: not resolved