Context.values.get for secret return undefined

I have and secret “sendgrid_api_key” defined in Realm UI!
Screenshot 2020-12-07 at 00.17.35|690x282
When I try to get this value inside the function it returns undefined.

exports = async (username, tokenId, token) => {

  console.log("sendgrid_api_key", context.values.get("sendgrid_api_key"));

  const body = {
    personalizations: [{ to: [{ email: username }] }],
    from: { email: "" },
    subject: `Hi ${username} reset email`,
    content: [
        type: "text/plain",
        value: "test",

    url: "",
    headers: {
      Authorization: [`Bearer ${context.values.get("sendgrid_api_key")}`],
    body: JSON.stringify(body),
    encodeBodyAsJSON: true,

Executing this function logs sendgrid_api_key undefined
What am I doing wrong?

1 Like

Ok, nevermind I just found solution in docs

You cannot directly read the value of a Secret after defining it. Instead, you link to the Secret by name in authentication provider and service configurations. If you need to access the Secret from a Function or Rule, you can link the Secret to a Value.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.