如何使用 Axios 对使用 csrf 令牌的网站进行身份验证

编程入门 行业动态 更新时间:2024-10-04 07:27:52

如何使用 Axios 对使用 csrf <a href=https://www.elefans.com/category/jswz/34/1771317.html style=令牌的网站进行身份验证"/>

如何使用 Axios 对使用 csrf 令牌的网站进行身份验证

我要验证到该网站的网站 =%2fHomeAccess 并且它使用“__RequestVerificationToken”,当您进入该网站和令牌隐藏在html中。我登录时检查了有效负载并发送了:

const axios = require('axios');
const cheerio = require('cheerio');

axios.get('')
  .then((response) => {
    const $ = cheerio.load(response.data);
    const token = $('input[name="__RequestVerificationToken"]').val();

    const payload = {
      __RequestVerificationToken: token,
      SCKTY00328510CustomEnabled: 'True',
      SCKTY00436568CustomEnabled: 'True',
      Database: '10',
      VerificationOption: 'UsernamePassword',
      'LogOnDetails.UserName': 'TestName',
      tempUN: '',
      tempPW: '',
      'LogOnDetails.Password': 'TestPass'
    };

    return axios.post('', payload);
  })
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.error(error);
  });

当我尝试这个时,我得到的只是错误,我不确定为什么。

回答如下:

更多推荐

如何使用 Axios 对使用 csrf 令牌的网站进行身份验证

本文发布于:2024-05-30 11:13:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1770436.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:令牌   如何使用   身份验证   网站   csrf

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!