admin管理员组文章数量:1418706
const express = require("express");
const app = express();
const PORT = 3000;
require("dotenv").config();
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_TOKEN;
const client = require("twilio")(accountSid, authToken);
client.messages
.create({
to: process.env.NUMBER,
from: "+18598006707",
body: "Hello Kashif",
})
.then((message) => console.log(message.sid));
app.listen(PORT, () => {
console.log("server is at", PORT);
});
i am getting "accountSid must start with AC" even though my TWILIO_ACCOUNT_SID include AC.
TWILIO_ACCOUNT_SID="ACa6213af064b**************";
TWILIO_TOKEN="b5e1f89ed92c7c5****************";
NUMBER="+91783******";
const express = require("express");
const app = express();
const PORT = 3000;
require("dotenv").config();
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_TOKEN;
const client = require("twilio")(accountSid, authToken);
client.messages
.create({
to: process.env.NUMBER,
from: "+18598006707",
body: "Hello Kashif",
})
.then((message) => console.log(message.sid));
app.listen(PORT, () => {
console.log("server is at", PORT);
});
i am getting "accountSid must start with AC" even though my TWILIO_ACCOUNT_SID include AC.
TWILIO_ACCOUNT_SID="ACa6213af064b**************";
TWILIO_TOKEN="b5e1f89ed92c7c5****************";
NUMBER="+91783******";
Share
Improve this question
edited Mar 9, 2022 at 14:25
kashif
asked Mar 9, 2022 at 13:57
kashifkashif
512 silver badges6 bronze badges
2 Answers
Reset to default 6Can I assume the second code snippet you shared is your .env file? If so, the .env file does not support semicolons. If I put semicolons in my .env file and run your script, I get the same error as you. Try updating your .env file like this:
TWILIO_ACCOUNT_SID="ACa6213af064b**************"
TWILIO_TOKEN="b5e1f89ed92c7c5****************"
NUMBER="+91783******"
Once I did that, it started working for me.
To confirm whether your .env file is loaded correctly, you can try logging accountSid
and other variables from process.env
, and verify it matches your .env file values.
Another cause for the above error can be the variables in .env file being ahead or behind of the variable values in your terminal, in which case it can be resolved by running source .env
.
本文标签: javascripttwilio error quotaccountSid must start with ACquotStack Overflow
版权声明:本文标题:javascript - twilio error "accountSid must start with AC" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745253449a2649959.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论