Please excuse our look. We're just getting started here.
Want to learn more about Twilio Forums? Check out our FAQ page here.Error: Twilio.Exceptions.AuthenticationException: 'Username can not be null'

Hello everyone! I'm trying to use Twilio for an app that I'm working on, but I'm getting an error "Twilio.Exceptions.AuthenticationException: 'Username can not be null'". I'm using C# ASP.NET and Xamarin. Here's the part of the code:
// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
string accountSid = Environment.GetEnvironmentVariable("************"); (obviously I'll censor some sensible information)
string authToken = Environment.GetEnvironmentVariable("************");
string mensagem = "******";
string numeroTelefone = "+55" + DataEntry.Text;
TwilioClient.Init(accountSid, authToken);
var message = MessageResource.Create(
body: mensagem,
from: new Twilio.Types.PhoneNumber("********"),
to: new Twilio.Types.PhoneNumber(numeroTelefone)
);
do you guys have any ideas what may be causing the error? do I need to settle my Twilio username and password in the code, or just ID and authToken should work? Thanks if you took your time to answer me!
EDIT: Solved. I was trying to use my ID as an environment variable but forgot to set it first.
Comments
-
Happy to hear you got your issue solved on your own @Aequilux. Hope to see you on the Forum again soon!
Categories
- 83 All Categories
- 19 SIGNAL 2021
- 376 Product Discussions
- 7 Community - Announcements
- 2 Changelog
- 4 Forum UI Updates
- 8 Welcome Guide
- 6 Community - Events
- 2 Twilio Relay Developer Conference 2021 Mega Thread
- 1 External Community Events
- 25 Inspiration
- 17 Community - Other Discussions
- 1 Community- Twilio Startups