Title: REST API anonymous POST
Last modified: July 3, 2017

---

# REST API anonymous POST

 *  [everyone.pause](https://wordpress.org/support/users/pause13th/)
 * (@pause13th)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/rest-api-anonymous-post/)
 * Hello there!
 * I’m currently messing around with REST API to make CustomPostType-Contact to 
   collect ‘Contact Information’ from ANY users via form submission
 * However when I ‘POST’ without any login, it return 401 and says I’m unauthorized.
 * I’m still reading up on basic authentication and oauth, but not sure where to
   go from here. Am I missing something here?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/rest-api-anonymous-post/#post-9285151)
 * Yes, the default cookie authentication requires the user to be logged in in order
   to work. To accommodate random visitors, you could log in for them “behind the
   scene” using a generic user account. It’s probably better to use one of the [authentication plugins](https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/#authentication-plugins).
   Go with which ever one best meets your needs.
 * I’ve no experience with any of these plugins. The oAuth concept in general works
   very nicely, but correctly setting it up can be challenging. I don’t know if 
   the REST oAuth plugin helps any with this or not. JSON tokens sounds appealing,
   I’d be inclined to give it a try first.
 *  Thread Starter [everyone.pause](https://wordpress.org/support/users/pause13th/)
 * (@pause13th)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/rest-api-anonymous-post/#post-9286006)
 * Hey thanks bcworkz!
 * thanks for the suggestion! will definitely try login user from behind the scene
   without plugin for now, before dig deeper with oAuth or JSON token 🙂
 *  Thread Starter [everyone.pause](https://wordpress.org/support/users/pause13th/)
 * (@pause13th)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/rest-api-anonymous-post/#post-9293886)
 * Just to add for anyone stumble upon this question:
 * I just found out there are a function for users to submit ajax without privilege(
   non log-in user). Instead of going through the whole trouble of login for random
   strangers, the function below make more sense :p
 * **wp_ajax_nopriv_[action_name]**
    reference: [https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_nopriv_(action)](https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_nopriv_(action))

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘REST API anonymous POST’ is closed to new replies.

## Tags

 * [anonymous](https://wordpress.org/support/topic-tag/anonymous/)
 * [post](https://wordpress.org/support/topic-tag/post/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 2 participants
 * Last reply from: [everyone.pause](https://wordpress.org/support/users/pause13th/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/rest-api-anonymous-post/#post-9293886)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
