简体   繁体   中英

wordpress json api and ajax login

I am working on a wordpress theme based on AngularJS framework, I already setup WP REST API and it is accessible from the /wp-json, My login form is ajax driven (AngularJS controller) now I am looking for a way to authenticate my users against wordpress back-end, I searched all over docs, it says cookie authentication is applicable in this case. it also talks of sending "nonce" for each parameter but there is no clue on how to send username/password for first time authentication from within ajax request. Does json rest api support sending username/password ? it seems there is no routes to it.

I think i am missing something fundamental/

There are three types of authentication are the here is the document for the authentication.

http://wp-api.org/guides/authentication.html

You need to login using basic authentication method then wordpress will automatically set the cookies for the login user and you need not manage the cookie in your end.

PHP Client https://github.com/WP-API/client-php

JS CLient https://github.com/WP-API/client-js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM