403 Firebase云功能的状态->;谷歌图书API
我目前正在创建一个Firebase云函数,该函数从《纽约时报》API检索图书列表,并从谷歌图书API获取一些附加信息。通过使用以下URL::&key=“我能够根据ISBN检索书籍的详细信息 我对GoogleBooksAPI的免费配额是每天1000个请求,每个用户每100秒100个请求。我只发送了15个请求,而我目前的配额不足200个 我的密钥仅限于与Google Books API一起使用,可以在任何地方使用(iOS、web、android等) 构建函数后,我将在本地测试所有内容,并正确填充数据,尽管在firebase上部署函数后,我在尝试访问API时会收到403状态代码 不幸的是,我没有得到关于错误的更多细节。它只是这样:403 Firebase云功能的状态->;谷歌图书API,firebase,google-cloud-functions,axios,http-status-code-403,google-books,Firebase,Google Cloud Functions,Axios,Http Status Code 403,Google Books,我目前正在创建一个Firebase云函数,该函数从《纽约时报》API检索图书列表,并从谷歌图书API获取一些附加信息。通过使用以下URL::&key=“我能够根据ISBN检索书籍的详细信息 我对GoogleBooksAPI的免费配额是每天1000个请求,每个用户每100秒100个请求。我只发送了15个请求,而我目前的配额不足200个 我的密钥仅限于与Google Books API一起使用,可以在任何地方使用(iOS、web、android等) 构建函数后,我将在本地测试所有内容,并正确填充数据
{ Error: Request failed with status code 403
at createError (/user_code/node_modules/axios/lib/core/createError.js:16:15)
at settle (/user_code/node_modules/axios/lib/core/settle.js:18:12)
at IncomingMessage.handleStreamEnd (/user_code/node_modules/axios/lib/adapters/http.js:201:11)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
config:
{ adapter: [Function: httpAdapter],
transformRequest: { '0': [Function: transformRequest] },
transformResponse: { '0': [Function: transformResponse] },
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: [Function: validateStatus],
headers:
{ Accept: 'application/json, text/plain, */*',
'User-Agent': 'axios/0.18.0' },
method: 'get',
url: 'https://www.googleapis.com/books/v1/volumes?q=isbn:0525520384&key=##########’,
data: undefined },
request:
ClientRequest {
domain: null,
_events:
{ socket: [Function],
abort: [Function],
aborted: [Function],
error: [Function],
timeout: [Function],
prefinish: [Function: requestOnPrefinish] },
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedHeader: {},
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 10,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: 'www.googleapis.com',
_readableState: [Object],
readable: false,
domain: null,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
destroyed: true,
_bytesDispatched: 210,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular],
read: [Function],
_consuming: true,
write: [Function: writeAfterFIN],
_idleNext: null,
_idlePrev: null,
_idleTimeout: -1 },
connection:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 10,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: 'www.googleapis.com',
_readableState: [Object],
readable: false,
domain: null,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
destroyed: true,
_bytesDispatched: 210,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Circular],
read: [Function],
_consuming: true,
write: [Function: writeAfterFIN],
_idleNext: null,
_idlePrev: null,
_idleTimeout: -1 },
_header: 'GET /books/v1/volumes?q=isbn:0525520384&key=##### HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nUser-Agent: axios/0.18.0\r\nHost: www.googleapis.com\r\nConnection: close\r\n\r\n',
_headers:
{ accept: 'application/json, text/plain, */*',
'user-agent': 'axios/0.18.0',
host: 'www.googleapis.com' },
_headerNames: { accept: 'Accept', 'user-agent': 'User-Agent', host: 'Host' },
_onPendingData: null,
agent:
Agent {
domai
通过对密钥添加更多限制(仅限HTTP)并向请求添加referer头,最后在请求末尾添加国家代码,我原来的问题现在消失了 注意:Referer应该与密钥上的http限制值匹配 最终网址:
通过对密钥添加更多限制(仅限HTTP)并向请求添加referer头,最后在请求末尾添加国家代码,我原来的问题现在消失了 注意:Referer应该与密钥上的http限制值匹配 最终网址:
我也面临着类似的问题。当我在本地运行我的函数时(即
firebase-service
),我能够成功地使用Books-API。但是当我将这些功能和应用程序部署到主机上时,我得到了一个神秘的403:probled
错误
我尝试了几种方法,因此我不确定哪种方法有效,因此我将列出所有方法:
- 更新的firebase函数:
npm安装--保存firebase-functions@latest
- 从使用
切换到使用node fetch
调用APIaxios
- 将国家/地区添加到URL:
https://www.googleapis.com/books/v1/volumes?country=US&q=insubject:${randomWord}&key=${functions.config().books.api.key}
- 重新生成Google Books API密钥
- 删除了google云控制台中的所有
应用程序限制
希望这能帮助别人,因为我和它搏斗了好几个小时 我也面临着类似的问题。当我在本地运行我的函数时(即
firebase-service
),我能够成功地使用Books-API。但是当我将这些功能和应用程序部署到主机上时,我得到了一个神秘的403:probled
错误
我尝试了几种方法,因此我不确定哪种方法有效,因此我将列出所有方法:
- 更新的firebase函数:
npm安装--保存firebase-functions@latest
- 从使用
切换到使用node fetch
调用APIaxios
- 将国家/地区添加到URL:
https://www.googleapis.com/books/v1/volumes?country=US&q=insubject:${randomWord}&key=${functions.config().books.api.key}
- 重新生成Google Books API密钥
- 删除了google云控制台中的所有
应用程序限制
希望这能帮助别人,因为我和它搏斗了好几个小时 谷歌图书API需要了解国家才能展示相关图书。可以通过country参数传递它,也可以使用客户端直接调用api。Google books api需要知道国家才能显示相关书籍。通过country参数传递它,或者您可以使用客户端直接调用api的。错误可能是对该端点的Forbbiden访问,可能是由于错误的Apikey错误可能是对该端点的Forbbiden访问,可能是因为APIKEY错误,这应该是一个问题而不是答案。这应该是一个问题而不是答案。是否有办法将api密钥限制为仅使用http云函数?我不想删除所有的应用限制哇,谢谢你。这是国家参数。在本地调用API工作得很好,但是从函数调用给了我403。当我添加country参数时才开始在函数中工作,我似乎找不到该参数的文档。是否有方法将api密钥限制为仅http云函数?我不想删除所有的应用限制哇,谢谢你。这是国家参数。在本地调用API工作得很好,但是从函数调用给了我403。当我添加了country参数时,才开始在函数中工作,我似乎找不到该参数的文档。