在Cakephp3中启用Csrf组件时.我如何在ajax调用中使用它.在此beforeSend参数中,ajax csrf标记在标头中设置.什么是价值csrfToken.因为它给出了错误
csrfToken未定义
beforeSend: function(xhr){
xhr.setRequestHeader('X-CSRF-Token', csrfToken);
},
Run Code Online (Sandbox Code Playgroud)
另外,如何禁用某些ajax调用的Csrf组件.
我运行此代码,但它给出错误:redirect_uri_mismatch.我在client_secret.json文件中设置重定向uri.但每次重定向uri都像http:// localhost:53271/Callback(端口号每次更改)但不是我在client_secret.json中给出的那个.
public class SheetsQuickstart {
private static final String APPLICATION_NAME = "Web client 1";
private static final java.io.File DATA_STORE_DIR = new java.io.File(
System.getProperty("user.home"), ".credentials/sheets.googleapis.com-java-quickstart");
/** Global instance of the {@link FileDataStoreFactory}. */
private static FileDataStoreFactory DATA_STORE_FACTORY;
/** Global instance of the JSON factory. */
private static final JsonFactory JSON_FACTORY =
JacksonFactory.getDefaultInstance();
/** Global instance of the HTTP transport. */
private static HttpTransport HTTP_TRANSPORT;
/** Global instance of the scopes required by this quickstart.
*
* If modifying …Run Code Online (Sandbox Code Playgroud)