I have tried many things to deploy this function, installing and uninstalling node many times and many more tries but it still giving me same error. What I am trying to achieve is using agora-access-token package to generate token using firebase function the code is:
const functions = require("firebase-functions");
const {RtcTokenBuilder, RtcRole} = require("agora-access-token");
exports.agoraToken = functions.region("asia-south1").
https.onCall((data, context)=> {
const appID = "<myAppID>";
const appCertificate = "myAppCertificate";
const uid = data.uid;
const channelId = data.channelId;
const role = RtcRole.PUBLISHER;
const expirationTimeInSeconds = 3600;
const currentTimestamp = Math.floor(Date.now() / 1000);
const privilegeExpiredTs = currentTimestamp + expirationTimeInSeconds;
const token = RtcTokenBuilder.buildTokenWithUid(appID,
appCertificate, channelId, uid, role, privilegeExpiredTs);
return token;
});
And the error is:
=== Deploying to 'xxxx'...
I deploying functions Running command: npm --prefix "$RESOURCE_DIR" run lint
lint eslint.
- functions: Finished running predeploy script. i functions: ensuring required API cloudfunctions.googleapis.com is enabled... i functions: ensuring required API cloudbuild.googleapis.com is enabled... i functions: ensuring required API artifactregistry.googleapis.com is enabled...
- functions: required API artifactregistry.googleapis.com is enabled
- functions: required API cloudfunctions.googleapis.com is enabled
- functions: required API cloudbuild.googleapis.com is enabled i functions: preparing functions directory for uploading... i functions: packaged functions (71.53 KB) for uploading
- functions: functions folder uploaded successfully i functions: creating Node.js 14 function agoraToken(asia-south1)...
Functions deploy had errors with the following functions: agoraToken(asia-south1) i functions: cleaning up build files...
Error: There was an error deploying functions
What I can propose is that you use --debug
because it provides information not found in the logs, and it can also fix a problematic deployment.
Try running the deployment with --debug. Example: firebase --debug deploy.
Cloud Function logs can be seen in the Firebase dashboard, the Cloud Logging UI, or the firebase command-line tool.
To view more logs, here is the link to the documentation.
The problem was that I did not added dependency in package.json file. I had to add agora-access-token dependency in package.json in function folder.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.