我一直在尝试将Zoho会议与我的应用程序集成(React是前端,Django是后端)。
在获取访问令牌时,我得到以下错误。
Access to fetch at 'https://accounts.zoho.com/oauth/v2/token?code=1000.53axxxxxxxxxxxxxxxxxxxxxxxxxx2e8e5eb43cfe53005f8d93490&client_id=1000.PGPL8RK7R54UR7JSNKTM2ZRETSF4CI&client_secret=xxxxxxxxxxxxxxxxxxx&redirect_uri=http://localhost:3000/app_store/zoho_meet&grant_type=authorization_code' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
这是我的axios代码部分
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json',
"Access-Control-Allow-Origin": "*",
}
})
const url = `https://accounts.zoho.com/oauth/v2/token?code=${zcode}&client_id=1000.xxxxxxxxxxxxxxxI&client_secret=92821f12d14cf11162891xxxxxxxxxxxxxxxxxxxx&redirect_uri=http://localhost:3000/app_store/zoho_meet&grant_type=authorization_code`
publicAxios.get(url)
.then((res)=>{
console.log(res)
})
.catch((err)=>{
console.log(err)
})
'这里有人能帮我吗?我错过了什么舞步?
1条答案
按热度按时间qncylg1j1#
我可以使用Netlify的无服务器函数从我的React应用程序连接到Zoho API。(AWS Lambda函数在引擎盖下)我通过无服务器函数进行所有Api调用。Api调用Zoho失败,在浏览器(客户端)运行时出现CORS错误。它必须在服务器上运行。也可以使用Google函数,但我没有尝试过。Netlify文档很棒。