Created
August 25, 2021 05:10
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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