[英]Firebase Functions and Autodesk Forge integration
I have a problem with a fetch request inside Firebase Functions for the Autodesk Forge Token. 我在Firebase Functions中获取Autodesk Forge令牌的获取请求时遇到问题。
Here is the error that is showing on functions registrations: 这是函数注册中显示的错误:
FetchError: request to https://developer.api.autodesk.com/authentication/v1/authenticate failed, FetchError:对https://developer.api.autodesk.com/authentication/v1/authenticate的请求失败,
reason: getaddrinfo EAI_AGAIN developer.api.autodesk.com:443
at ClientRequest.<anonymous> (/srv/node_modules/node-fetch/lib/index.js:1455:11)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at TLSSocket.socketErrorListener (_http_client.js:401:9)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:66:8)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)
I have already tried inserting the Forge API inside my react js project, and figure it out it would be a CORS problems. 我已经尝试过在我的react js项目中插入Forge API,并弄清楚这将是一个CORS问题。
const snapshot = change.after;
console.log(snapshot)
const api = "https://developer.api.autodesk.com/authentication/v1/authenticate"
const search = () =>
fetch(`${api}`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: JSON.stringify(`client_id=${process.env.REACT_APP_FORGE_CLIENT_ID}&client_secret=${process.env.REACT_APP_FORGE_CLIENT_SECRET}&grant_type=client_credentials&scope=data:read`)
}).then(res => res.json())
search().then((res) => {
const data = res
return snapshot.ref.parent.child('token').set(data);
})
})
Since Firebase Functions runs in the GCD backend CORS does not really come into play ... 由于Firebase Functions在GCD后端中运行,CORS并没有真正发挥作用。
You must be on the free plan - getaddrinfo EAI_AGAIN
indicates a DNS lookup timeout and is due to the limitations of the free tier where outbound networking is limited to within Google services. 您必须采用免费计划
getaddrinfo EAI_AGAIN
表示DNS查找超时,并且是由于免费层的限制,其中出站网络仅限于Google服务。 Upgrade your plan to Flame or Blaze . 将您的计划升级到Flame或Blaze 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.