无法从React JS应用程序调用WSO2 IS 5.9.0 api吗?

问题描述 投票:0回答:1

我正在使用axios在react js上进行api调用

Headers------>
import axios from 'axios';

const apiURL =
process.env.NODE_ENV !== 'production'
? 'https://MY IP:9443/'
: 'https://MY IP:9443/';

const myHeaders = {
Accept: 'application/json',
'Authorization': 'Basic /-My Header converted to base64 with username:password format',
'Content-Type': 'application/x-www-form-urlencoded'
};

axios.defaults.baseURL = apiURL;
axios.defaults.headers = myHeaders;

async function post(url, payload = '') {
return await axios.post(`${url}`, payload);
}

export default {
post
};
API CALL----->
senddata = e => {
    e.preventDefault();
    e.stopPropagation();
    this.setState({
        handleLoginLoading: true,
    });

    const payload = {
        grant_type: 'password',
        username: this.state.email,
        password: this.state.password
    };

    loginApiUrl
      .post('/oauth2/token', payload)
      .then(response => {
          if (response.data.result.type == 'test_taker') {
              this.setLoginParams(response.data.result, this.state.rememberme);
          } else {
              this.setState({
                  showSnackbar: true,
                  snackbarVariant: 'error',
                  snakBarMessage: 'Invalid Login',
                  position: 'center',
                  handleLoginLoading: false,
              });
          }
      })
      .catch(err => {
        console.log(err)
        handleLoginLoading: false
      });
};

我的基本URL的格式为'x.x.x.x:9443',其中x是数字

我面临的错误是

OPTIONS https://IP:9443/oauth2/token net::ERR_CERT_AUTHORITY_INVALID

我这样做失败,并且无法将我的Web应用程序与身份服务器集成在一起

请帮助我解决我的问题,如果您能提供详细的步骤,这将非常有帮助?谢谢

reactjs wso2 axios wso2is wso2carbon
1个回答
0
投票

这是证书验证问题。由于您尝试在本地访问它,因此暂时的解决方案是在浏览器上导航至https://IP:9443/oauth2/tokenhttps://localhost:9443/oauth2/token并添加一个例外。

© www.soinside.com 2019 - 2024. All rights reserved.