From 8f378d3b3566917954bc7405dec2428a19ef8396 Mon Sep 17 00:00:00 2001 From: John Doty Date: Thu, 29 Sep 2016 10:33:57 -0700 Subject: [PATCH] Quip secrets --- .emacs.d/custom.el | 2 ++ .emacs.d/quip.el | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.emacs.d/custom.el b/.emacs.d/custom.el index 7b5a80b..0994754 100644 --- a/.emacs.d/custom.el +++ b/.emacs.d/custom.el @@ -31,6 +31,8 @@ '(org-export-backends (quote (ascii html icalendar latex md))) '(org-hide-leading-stars t) '(org-odd-levels-only t) + '(quip-api-key + "UU9RQU1BcTNCdU0=|1506626374|H13gPE9bkDAkHQp9PtTlX8i78wYvtSBwEJgLAuChnXs=") '(rmail-mail-new-frame t) '(safe-local-variable-values (quote diff --git a/.emacs.d/quip.el b/.emacs.d/quip.el index 5850985..8969358 100644 --- a/.emacs.d/quip.el +++ b/.emacs.d/quip.el @@ -4,16 +4,23 @@ (require 'json) (require 'url) -;; TODO: Make this actually a variable. -(defconst doty-quip-api-key - "UU9RQU1BcTNCdU0=|1506626374|H13gPE9bkDAkHQp9PtTlX8i78wYvtSBwEJgLAuChnXs=") +;; Customization groups +(defgroup quip-api nil + "Customization options for using the Quip API") + +(defcustom quip-api-key nil + "Your API key for Quip. Get it from https://fb.quip.com/api/personal-token" + :type 'string) (defun quip-invoke-json (path method params) "Submit a request to the Quip API. Returns the parsed JSON from the response." + (if (not quip-api-key) + (error "The custom variable quip-api-key is undefined. +Use custom-set-variable to set it before using quip.")) (let ((url (concat "https://platform.quip.com/1/" path)) (url-request-method method) - (url-request-extra-headers `(("Authorization" . ,(concat "Bearer " doty-quip-api-key)) + (url-request-extra-headers `(("Authorization" . ,(concat "Bearer " quip-api-key)) ("Content-Type" . "application/x-www-form-urlencoded"))) (url-request-data (mapconcat (lambda (pair) (format "%s=%s" (car pair) (url-hexify-string (cdr pair))))