admin-ajax.php access and authentication

129 Views Asked by At

I am super new to wordpress/learnpress.

Have created a new function.

add_action( 'wp_ajax_updateCourseTimer', 'updateCourseTimer',10,4); add_action( 'wp_ajax_nopriv_updateCourseTimer', 'updateCourseTimer',10,4); function updateCourseTimer() { }

The call to the endpoint https://example.com/site.com/wp-admin/admin-ajax.php with action = updateCourseTimer works fine.

Now I need to call the same function from a mobile app. From the mobile app the call leveraging action "wp_ajax_nopriv_updateCourseTimer" works but call leveraging "wp_ajax_updateCourseTimer" doesn't work. It is basically an authentication issue.

I tired making calls with logged in user from the app but still no luck.

Question: How can one authenticate the call from an external system (mobile app), so that calls do not require nopriv routes. Do I need to somehow manually pass cookies from the ajax call in the app?

Again I am super new to all this and would appreciate guidance.

Thanks

With experimentation have figured out that its authentication issue. read about nonce etc. but not clear how to go about doing this.

0

There are 0 best solutions below