Javascript Axios从dart获取令牌';渡槽

Javascript Axios从dart获取令牌';渡槽,javascript,vue.js,dart,axios,aqueduct,Javascript,Vue.js,Dart,Axios,Aqueduct,使用javascriptaxios我试图从dart的导水管中获取令牌。 渡槽在后端使用oauth2规范,并且它有用于在dart上获取的示例代码。 Dart代码正在运行: var clientID = "com.app.demo"; var clientSecret = "mySecret"; var body = "username=bob@stablekernel.com&password=foobar&grant_type=password"; var clientCrede

使用javascript
axios
我试图从dart的
导水管中获取令牌。
渡槽在后端使用
oauth2
规范,并且它有用于在dart上获取的示例代码。 Dart代码正在运行:

var clientID = "com.app.demo";
var clientSecret = "mySecret";
var body = "username=bob@stablekernel.com&password=foobar&grant_type=password";
var clientCredentials = Base64Encoder().convert("$clientID:$clientSecret".codeUnits);

var response = await http.post(
  "https://stablekernel.com/auth/token",
  headers: {
    "Content-Type": "application/x-www-form-urlencoded",
    "Authorization": "Basic $clientCredentials"
  },
  body: body);
话虽如此,我正在为我的
vuejs
应用程序尝试axios。 下面是我正在尝试的代码:

const url = 'http://localhost:8888/auth/token';
    const encodedSecret = Buffer.from('com.local.test:').toString('base64')
    return  Axios({
        method: 'POST',
        url,
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
            "Authorization": `Basic ${encodedSecret}`
        },
        data: `username=${username}&password=${password}&grant_type=password`
    }).then((response)=>{
        console.log(response)
     })
        .catch((error) => {
            console.log(' error:', error)
        });
我总是收到
错误请求
错误代码
400

我做错了什么?如何取回代币?刷新令牌也是以后必须担心的问题。

我对axios不熟悉。。不过,尽管建议先在postman上测试端点,以确保一切正常,但我对axios并不熟悉。。尽管建议先在postman上测试端点,以确保一切正常