|
|
|
|
@ -3,21 +3,25 @@
|
|
|
|
|
(in-package :seanut)
|
|
|
|
|
|
|
|
|
|
(defun get-access-token (domain options)
|
|
|
|
|
(if (getf options :quick-connect-p)
|
|
|
|
|
(let ((token
|
|
|
|
|
(if (getf options :quick-connect-p)
|
|
|
|
|
|
|
|
|
|
;; go through the whole quick connect rigamarole
|
|
|
|
|
(quick-connect-dance domain)
|
|
|
|
|
;; go through the whole quick connect rigamarole
|
|
|
|
|
(quick-connect-dance domain)
|
|
|
|
|
|
|
|
|
|
;; authenticates the user via username and password
|
|
|
|
|
(gethash "AccessToken"
|
|
|
|
|
(json-request (format-url domain "Users/AuthenticateByName")
|
|
|
|
|
(generate-authorization "")
|
|
|
|
|
:method :post
|
|
|
|
|
:content `(("Username" . ,(getf options :username))
|
|
|
|
|
("Pw" . ,(getf options :password)))))))
|
|
|
|
|
;; authenticates the user via username and password
|
|
|
|
|
(gethash "AccessToken"
|
|
|
|
|
(json-request (format-url domain "Users/AuthenticateByName")
|
|
|
|
|
(generate-authorization)
|
|
|
|
|
:method :post
|
|
|
|
|
:content `(("Username" . ,(getf options :username))
|
|
|
|
|
("Pw" . ,(getf options :password))))))))
|
|
|
|
|
(format t "Your access token: ~A~&Next time you use seanut, pass this with -t to skip having to authorize~&"
|
|
|
|
|
token)
|
|
|
|
|
token))
|
|
|
|
|
|
|
|
|
|
(defun quick-connect-dance (domain)
|
|
|
|
|
(let* ((auth (generate-authorization ""))
|
|
|
|
|
(let* ((auth (generate-authorization))
|
|
|
|
|
(qc-session (handler-case
|
|
|
|
|
(json-request (format-url domain "QuickConnect/Initiate") auth)
|
|
|
|
|
(dex:http-request-unauthorized ()
|
|
|
|
|
|