How to get a person's username in Python ( os module )

To get someones username to personalise a project or secure a project then you use the code: import os

username = os.environ['REPL_OWNER']
Thanks for reading. I could also post a tutorial on how to use this soon.

4 Likes

https://replit.com/@HenryMiles3/DraftyPeskyConstant?v=1 Here is a project with the code.

Yes! This is a really good alternative to replit auth! I also use this for my chatbot!
It is sooo useful! I use it in almost every repl I use.

Always happy to help :smiley:

as long as you don’t use REPL_OWNER in any auth/verification process, then it should be safe. Otherwise, use REPL_IDENTITY which is signed and most likely can’t be tampered with.

Ok I’ll test that out.

Unfortunately, that’s not true. If someone can get access to env vars (even from cover page!), they can break the security of REPL_IDENTITY.

you can do that from the cover page?

Yes, see this topic:

That’s sad that we can’t protect stuff like that.

1 Like

You could vote on this feature request, and perhaps it’ll eventually get implemented in some form.

1 Like

I was about to say perhaps we should request a new feature to protect stuff.

1 Like

hey there guys, vuln hunter here, I want to say that it is guaranteed to be the correct user with a like <0.1% chance of hacking with repl_identity but it’s just that you cannot guarantee that the person is not automating the code

2 Likes