Ask coding questions

← Back to all posts
How to get os.environ['SECRET'] working for other users?
normalF

Hello!
I have been trying to get a program to work in Replit apps with secrets contained in it, like in this example.
But as you can see, it raises KeyError as if the secret's key is wrong. This works completely fine for me when I'm logged in.
I read the documentation for this, but it doesn't make sense that an unedited version of the code would restrict the use of secrets.
Am I missing something obvious?
Thanks!

Answered by CosmicBear [earned 5 cycles]
View Answer
Voters
CyberHacker101
normalF
Comments
hotnewtop
CosmicBear

The secrets don't exist for other users. It only exists for your account. To other accounts, they aren't there.

normalF

Thanks! I will need to find a workaround for this...
@CosmicBear

CyberHacker101

This might help.

EDIT:
mental note- check grammar before you comment you moron xD @youtubemirror

normalF

Close, but no cigar. It now outputs None, which is closer to what I want it to output.
(It should be:
this
that)
@CyberHacker101

CyberHacker101

It's surprising because most of the time my advice just causes more problems but IT HELPED?!?

Anyways I've never learned python so I'm no help, but I think I know a guy that can help you. @youtubemirror

Are ye willing to take da challenge? The choice is up to you. @Coder100

CyberHacker101

Also what in god's tarnation do you mean "this that"?
Is it a python thang I don't know about or what? @youtubemirror

CyberHacker101

oof yer late '100 sorry for da ping D:

CyberHacker101

in a unrelated topic have you ever used github before? @youtubemirror

normalF

Not so much, but it might be useful to me in the future. @CyberHacker101

CyberHacker101

oof ok its me first time usin it n I'm kinda confused Ill figure it out later ty for the reply @youtubemirror

CyberHacker101

Also what are you usin this program for? @youtubemirror

normalF

I wanted to make a program that lets the user scrape Reddit for post info on their own. I guess in hindsight it was kind of pointless to link my entire account to a public program if I wanted to keep the keys a secret. I have since then changed it so that you have to put in your own keys to get the scraping functionality.
@CyberHacker101

CyberHacker101

OOOOOOOOh
hmm i think ive seen someone on here do it
You can use the "Talk" section to see it
@normalF

normalF

AN IMPORTANT NOTE:
os.environ[] was working for me while logged out before, but it suddenly stopped working. Hope this clears some things up.