Ask coding questions

← Back to all posts
Replit Secrets
ruiwenge2 (602)

I'm kind of confused about Replit secrets. I tried using it by setting the key number to 2. Then I tried printing out the value. It worked when I was logged in, but not when I tried to see what would happen if I was logged out. I thought that Replit secrets were so that other people can't see the secret value in the code, but they could still use it?

Answered by OldWizard209 (1539) [earned 5 cycles]
View Answer
Comments
hotnewtop
OldWizard209 (1539)

Think of secrets in this way:
Replit creates a secret and stores it in a box.. The password to that box, is your account, meaning only when you are logged in, then only will you be able to see the value in the box.

But if you print the value, then it is just like as if you have put a sticker on the box saying what is inside the box so anyone can see it, but no one can manipulate it. Replit's job is to keep the secret and protect it. But if you print the value it , creating a secret is completely useless.

ruiwenge2 (602)

@OldWizard209 I am asking this question because i'm trying to create this thing that can send emails, which requires my gmail password. So i used a replit secret. But there is a key error if people who aren't me try to send emails

OldWizard209 (1539)

So are you trying to send the email from your gmail account to the requested email? @ruiwenge2

OldWizard209 (1539)

Firstly, this method of sending email is unsafe.

The reason you get a key error from another account or if you are logged out is because the replit's algorithm that looks for the secret, is meant to find the secret in your account, not from another user's account, even though the repl but my someone else's. If you want to send an email, create a throwaway account on Gmail, and use it to send emails.

Follow this tutorial for more info. Feel free to ask me any more questions. @ruiwenge2

OldWizard209 (1539)

Would you mind marking the answer then? Thanks @ruiwenge2