Quip secrets

This commit is contained in:
John Doty 2016-09-29 10:33:57 -07:00
parent 9d70f58244
commit 8f378d3b35
2 changed files with 13 additions and 4 deletions

View file

@ -31,6 +31,8 @@
'(org-export-backends (quote (ascii html icalendar latex md))) '(org-export-backends (quote (ascii html icalendar latex md)))
'(org-hide-leading-stars t) '(org-hide-leading-stars t)
'(org-odd-levels-only t) '(org-odd-levels-only t)
'(quip-api-key
"UU9RQU1BcTNCdU0=|1506626374|H13gPE9bkDAkHQp9PtTlX8i78wYvtSBwEJgLAuChnXs=")
'(rmail-mail-new-frame t) '(rmail-mail-new-frame t)
'(safe-local-variable-values '(safe-local-variable-values
(quote (quote

View file

@ -4,16 +4,23 @@
(require 'json) (require 'json)
(require 'url) (require 'url)
;; TODO: Make this actually a variable. ;; Customization groups
(defconst doty-quip-api-key (defgroup quip-api nil
"UU9RQU1BcTNCdU0=|1506626374|H13gPE9bkDAkHQp9PtTlX8i78wYvtSBwEJgLAuChnXs=") "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) (defun quip-invoke-json (path method params)
"Submit a request to the Quip API. Returns the parsed JSON from the response." "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 (let
((url (concat "https://platform.quip.com/1/" path)) ((url (concat "https://platform.quip.com/1/" path))
(url-request-method method) (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"))) ("Content-Type" . "application/x-www-form-urlencoded")))
(url-request-data (url-request-data
(mapconcat (lambda (pair) (format "%s=%s" (car pair) (url-hexify-string (cdr pair)))) (mapconcat (lambda (pair) (format "%s=%s" (car pair) (url-hexify-string (cdr pair))))