Failed to get Ali nail TOKEN

when using webpack + iview + axios, to get nail token, the following phenomenon occurs. The relevant JSON, has been obtained in the response, but ajax indicates that ERROR, does not know what the problem is, so solve it.

the AJAX code is as follows:

query: function () {
                let url = "https://oapi.dingtalk.com/gettoken";
                let CorpID = "xxxx";
                let CorpSecret = "xxxx";
                let accessTokenRequest = {
                    url: url,
                    method: "get",
                    params: {
                        corpid: CorpID,
                        corpsecret: CorpSecret
                    },
                };
                axios(accessTokenRequest).then(response => {
                    console.info(response);
                }).catch(error => {
                    console.info(error);
                });
            },
Mar.05,2021

Ali nails do not support cross-domain access at the frontend. You need to obtain the token from the backend and then return to the frontend. I use .net as the backend, the official does not provide SDK, need to write their own, need to use the httpRequest class (the IDE I use is vs2017, in the NuGet management package, the full name is FastHttpRequest), list the simple code as follows

Front-end html

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script src="Scripts/jquery-3.3.1.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("-sharpgetToken").click(function () {
                $.ajax({
                    type: "post",
                    url: "getToken.ashx",
                    success: function (data) {
                        console.info(data);
                    }, error: function () {
                        console.info("error");
                    }
                })
            });
        })
    </script>
</head>
<body>
    <button type="button" id ="getToken">token</button>
</body>
</html>

cs file

using System;
using System.Collections.Generic;
using HttpRequest;

namespace myDDDev
{
    public static class DDConfig
    {
        public static string __CorpID = "xxxx";  //corpId
        public static string __CorpSecret = "xxxxx"; //corpSecret
    }
    public class M_AccessToken
    {
        public string access_token { get; set; }
        public int errcode { get; set; }
        public string errmsg { get; set; }
    }
    public static class DDHelper
    {
        public static string GetAccessToken(string url)
        {

            if (url != "")
            {
                try
                {
                    HttpRequest.HttpHelper.HttpResult result = HttpRequest.HttpHelper.Get(url);
                    M_AccessToken oat = Newtonsoft.Json.JsonConvert.DeserializeObject<M_AccessToken>(result.ToStringResult());

                    if (oat != null)
                    {
                        if (oat.errcode == 0)
                        {
                            return oat.access_token;
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            return "";
        }
    }
}

ashx file

using System;
using System.Web;
using myDDDev;
using System.Web.SessionState;

public class getToken : IHttpHandler, IRequiresSessionState
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        //AccessToken https://oapi.dingtalk.com/gettoken?corpid=id&corpsecret=secrect GET
        string getUrl = string.Format("https://oapi.dingtalk.com/gettoken?corpid={0}&corpsecret={1}", DDConfig.__CorpID, DDConfig.__CorpSecret);

        //access_token ;
        string access_token = DDHelper.GetAccessToken(getUrl);
        context.Session["token"] = access_token;
        context.Response.Write("access_token:" + access_token);
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb1cbd-48166.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb1cbd-48166.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?