Secret

Show Deprecated

The Secret data type stores the secret content returned by HttpService:GetSecret(). It cannot be printed or logged, but can be modified using built-in functions, as demonstrated by the code block below.


local HttpService = game:GetService("HttpService")
local mySiteApiKey = HttpService:GetSecret("my_site")
local url = "https://apis.mysite.com?apiKey="
local urlWithKey = mySiteApiKey:AddPrefix(url)
local params = "&request=join&user=myname"
local resultingUrl = urlWithKey:AddSuffix(params)

Summary

Methods

Methods

AddPrefix

Returns a secret formed by concatenating the supplied string to the secret content, for example prepending "Bearer" to the API key.


local HttpService = game:GetService("HttpService")
local secret = HttpService:GetSecret("yelp")
local authHeader = secret:AddPrefix("Bearer ")

Parameters

prefix: string

Returns

AddSuffix

Returns a secret formed by concatenating the original secret and the supplied string parameter. Useful when creating a URL containing a key.


local HttpService = game:GetService("HttpService")
local googleMapsApiKey = HttpService:GetSecret("google_map")
local url = "https://maps.googleapis.com/maps/api/distancematrix/json destinations=" .. destination .. "&origins=" .. origin .. " departure_time=now&units=imperial&key="
local authedUrl = googleMapsApiKey:AddSuffix(url)

Parameters

suffix: string

Returns