Help with the secrets store

I’m trying to understand how to use this service,

local JoinWebhook = "https://discord.com/api/webhooks"..HttpService:GetSecret("JKWEB")
local Chatwebhook = "https://discord.com/api/webhooks"..HttpService:GetSecret("CHWEB")

issue is that they prompt an error
“Can’t find secret with given key”

does anyone know what’s the solution for this?

1 Like

You wrote “JKWEB” while your key is “JLWEB”

Also, by sharing the keys, didn’t you literally leak your webhooks

2 Likes

I’m just testing aha not really using it anywhere yet thanks anyway!

1 Like

In that case, was the mispelling the issue, or did you just mispell it when making this post?

1 Like

It’s yet to work btw it’s still prompting an error

2 Likes

I must’ve mispelled it because I did many changes in order to make it work

1 Like

It seems you cannot just add strings to it. You have to use special functions to do so.

That’s why I’m so confused aha, because I was suggested to use it and when I read others solutions for this type of problem it doesn’t work, so idk just weird…

In case you were using it locally, you can’t get secrets locally

Otherwise, perhaps double check the spelling again?

Secrets has its own functions which append it as a prefix of suffix to a string. Rather than concatenating with … I think you need to use these functions to add your URL to the secret. The secret has to be formatted so it makes sense in the total URL. The result is a new Secret which can be passed to the HttpService but is otherwise opaque.

local JoinWebhook = HttpService:GetSecret("JLWEB"):AddPrefix("https://discord.com/api/webhooks")
local Chatwebhook = HttpService:GetSecret("CHWEB"):AddPrefix("https://discord.com/api/webhooks")

FWIW, I had a hard time getting this to work. It’s tricky to debug since it works differently in Studio and it’s hard to see what the completed URL looks like.

2 Likes