0

So I was using a API and had to give my account username and password. I kept getting a authentication error, and was very confused.

After a lot of time it turns out that os.getenv("username") wasn't returning the environment vairable but instead my name. I checked the source code but in truth could not make sense of it lol. If anyone knows why this was the case and could tell me that would be awesome.

I know the module has something to do with the operating system but this was on the .env documentation so I'm just surprised it didn't work as expected.

here is the code all though I doubt it will be that useful, fixed since last commit: https://github.com/shers003/firstRedditbot

3
  • 1
    Is this on Windows? It seems like username is a built-in environment variable: rapidee.com/en/environment-variables. Could you just use another name that's not overlapping the one Windows uses? Commented Jan 5, 2021 at 19:45
  • Thank you for the link, I have gained some knowledge. Yep I did change the variable name and it works just fine now. Commented Jan 5, 2021 at 22:11
  • Okay, I'll post an answer so you can accept it. Commented Jan 5, 2021 at 22:13

1 Answer 1

1

According to this page, username is a built-in environment variable in Windows. The solution is to use a different name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.