Secrets not working in python

Problem Description:
when I run my project not sign in to the project cant find the environment variable.
below is a screenshot. At the top is the value of the secret.

Expected behavior:
I expect it to find my secret because I set it in secret.

Actual behavior:
The program can’t find the secret.

Steps to reproduce:
just set a secret in the secrets tab,

then have the program try to access the secret, then sign out and run projects

Bug appears at this link:
https://replit.com/@LevKnettle/fox-bank-secure-login?v=1

Browser/OS/Device:
ChormeOs, chorme.

other details

when you set a secret manually in a .replit file like this,

MYSECRET = "secret"

the program can find a secret, even when you’re running it sign out.

Repls cannot access secrets unless they are run by someone with edit access. That is by design.

3 Likes

but the program cant access the secret when it’s run by someone other than me

It’s a feature, not a bug.

1 Like

but technically I coded it to print the secret as a test here is code

from os import getenv
from os import scandir
from webbrowser import open as openurl
from time import sleep
from os import system
print(getenv("password"))
entris = scandir("time")
while True:
    password = input("enter password: ").strip()
    if password == getenv("password"):
        break
    else:
       print("incorrect password")
       sleep(2)
print(getenv("website"))
openurl(getenv("website"))

Then it is no longer secret. Those are actually called environment vars, and this kind is explicitly not secret and not meant for secrets

You coded it to print the secret if it exists, replit coded the secret to only “exist” if you are logged in. So the result is that you get None

3 Likes

so how do I set it so that other people could run the project and program still finding secrets while not being in code where people could find secrets?

You can’t. People would need to fork your project and manually input the secret.

2 Likes