Skip to content

Instantly share code, notes, and snippets.

@BenAtWide
Created August 25, 2021 05:10
Show Gist options
  • Save BenAtWide/21e6e6bba18ed883cdfec4ad72ae84fa to your computer and use it in GitHub Desktop.
Save BenAtWide/21e6e6bba18ed883cdfec4ad72ae84fa to your computer and use it in GitHub Desktop.
Use Drafts Credential object to ask a user for a secret the first time it is used, and store it securely in the app. This makes it easier to share scripts without requiring embedded secrets in the code.
// Use the Drafts Credential function to store the API key
var credential = Credential.create("Mem.ai", "The mem.ai web API. Generate your key in the Flows section of the mem app.");
credential.addTextField("apikey", "API Key");
credential.authorize();
// Retrieve the credential and add to the request headers
var headers = {
"Content-Type": "application/json",
"Authorization": "ApiAccessToken " + credential.getValue("apikey")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment